AlkantarClanX12

Your IP : 3.139.67.228


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/__pycache__/phpserialize.cpython-311.pyc

�

d��f�G��|�dZddlZ	ejd��dZn
#e$rdZYnwxYw	ddlmZn#e$r	ddlmZYnwxYw	e	n#e
$r	eZ	eefZ
YnwxYw	en
#e
$reZYnwxYw	en
#e
$reZYnwxYwdZdZd	Zd
�ZGd�de��Zd
�Zdedfd�Zdedddfd�Zdedddfd�Zdedfd�Zd�Zd�ZeZeZ dS)a�
    phpserialize
    ~~~~~~~~~~~~

    a port of the ``serialize`` and ``unserialize`` functions of
    php to python.  This module implements the python serialization
    interface (eg: provides `dumps`, `loads` and similar functions).

    Usage
    =====

    >>> from phpserialize import *
    >>> obj = dumps("Hello World")
    >>> loads(obj)
    'Hello World'

    Due to the fact that PHP doesn't know the concept of lists, lists
    are serialized like hash-maps in PHP.  As a matter of fact the
    reverse value of a serialized list is a dict:

    >>> loads(dumps(range(2)))
    {0: 0, 1: 1}

    If you want to have a list again, you can use the `dict_to_list`
    helper function:

    >>> dict_to_list(loads(dumps(range(2))))
    [0, 1]

    It's also possible to convert into a tuple by using the `dict_to_tuple`
    function:

    >>> dict_to_tuple(loads(dumps((1, 2, 3))))
    (1, 2, 3)

    Another problem are unicode strings.  By default unicode strings are
    encoded to 'utf-8' but not decoded on `unserialize`.  The reason for
    this is that phpserialize can't guess if you have binary or text data
    in the strings:

    >>> loads(dumps(u'Hello W\xf6rld'))
    'Hello W\xc3\xb6rld'

    If you know that you have only text data of a known charset in the result
    you can decode strings by setting `decode_strings` to True when calling
    loads:

    >>> loads(dumps(u'Hello W\xf6rld'), decode_strings=True)
    u'Hello W\xf6rld'

    Dictionary keys are limited to strings and integers.  `None` is converted
    into an empty string and floats and booleans into integers for PHP
    compatibility:

    >>> loads(dumps({None: 14, 42.23: 'foo', True: [1, 2, 3]}))
    {'': 14, 1: {0: 1, 1: 2, 2: 3}, 42: 'foo'}

    It also provides functions to read from file-like objects:

    >>> from StringIO import StringIO
    >>> stream = StringIO('a:2:{i:0;i:1;i:1;i:2;}')
    >>> dict_to_list(load(stream))
    [1, 2]

    And to write to those:

    >>> stream = StringIO()
    >>> dump([1, 2], stream)
    >>> stream.getvalue()
    'a:2:{i:0;i:1;i:1;i:2;}'

    Like `pickle` chaining of objects is supported:

    >>> stream = StringIO()
    >>> dump([1, 2], stream)
    >>> dump("foo", stream)
    >>> stream.seek(0)
    >>> load(stream)
    {0: 1, 1: 2}
    >>> load(stream)
    'foo'

    This feature however is not supported in PHP.  PHP will only unserialize
    the first object.

    Array Serialization
    ===================

    Starting with 1.2 you can provide an array hook to the unserialization
    functions that are invoked with a list of pairs to return a real array
    object.  By default `dict` is used as array object which however means
    that the information about the order is lost for associative arrays.

    For example you can pass the ordered dictionary to the unserilization
    functions:

    >>> from collections import OrderedDict
    >>> loads('a:2:{s:3:"foo";i:1;s:3:"bar";i:2;}',
    ...       array_hook=OrderedDict)
    collections.OrderedDict([('foo', 1), ('bar', 2)])

    Object Serialization
    ====================

    PHP supports serialization of objects.  Starting with 1.2 of phpserialize
    it is possible to both serialize and unserialize objects.  Because class
    names in PHP and Python usually do not map, there is a separate
    `object_hook` parameter that is responsible for creating these classes.

    For a simple test example the `phpserialize.phpobject` class can be used:

    >>> data = 'O:7:"WP_User":1:{s:8:"username";s:5:"admin";}'
    >>> user = loads(data, object_hook=phpobject)
    >>> user.username
    'admin'
    >>> user.__name__
    'WP_User'

    An object hook is a function that takes the name of the class and a dict
    with the instance data as arguments.  The instance data keys are in PHP
    format which usually is not what you want.  To convert it into Python
    identifiers you can use the `convert_member_dict` function.  For more
    information about that, have a look at the next section.  Here an
    example for a simple object hook:

    >>> class User(object):
    ...     def __init__(self, username):
    ...         self.username = username
    ...
    >>> def object_hook(name, d):
    ...     cls = {'WP_User': User}[name]
    ...     return cls(**d)
    ...
    >>> user = loads(data, object_hook=object_hook)
    >>> user.username
    'admin'

    To serialize objects you can use the `object_hook` of the dump functions
    and return instances of `phpobject`:

    >>> def object_hook(obj):
    ...     if isinstance(obj, User):
    ...         return phpobject('WP_User', {'username': obj.username})
    ...     raise LookupError('unknown object')
    ...
    >>> dumps(user, object_hook=object_hook)
    'O:7:"WP_User":1:{s:8:"username";s:5:"admin";}'

    PHP's Object System
    ===================

    The PHP object system is derived from compiled languages such as Java
    and C#.  Attributes can be protected from external access by setting
    them to `protected` or `private`.  This does not only serve the purpose
    to encapsulate internals but also to avoid name clashes.

    In PHP each class in the inheritance chain can have a private variable
    with the same name, without causing clashes.  (This is similar to the
    Python `__var` name mangling system).

    This PHP class::

        class WP_UserBase {
            protected $username;

            public function __construct($username) {
                $this->username = $username;
            }
        }

        class WP_User extends WP_UserBase {
            private $password;
            public $flag;

            public function __construct($username, $password) {
                parent::__construct($username);
                $this->password = $password;
                $this->flag = 0;
            }
        }

    Is serialized with a member data dict that looks like this:

    >>> data = {
    ...     ' * username':          'the username',
    ...     ' WP_User password':    'the password',
    ...     'flag':                 'the flag'
    ... }

    Because this access system does not exist in Python, the
    `convert_member_dict` can convert this dict:

    >>> d = convert_member_dict(data)
    >>> d['username']
    'the username'
    >>> d['password']
    'the password'

    The `phpobject` class does this conversion on the fly.  What is
    serialized is the special `__php_vars__` dict of the class:

    >>> user = phpobject('WP_User', data)
    >>> user.username
    'the username'
    >>> user.username = 'admin'
    >>> user.__php_vars__[' * username']
    'admin'

    As you can see, reassigning attributes on a php object will try
    to change a private or protected attribute with the same name.
    Setting an unknown one will create a new public attribute:

    >>> user.is_admin = True
    >>> user.__php_vars__['is_admin']
    True

    To convert the phpobject into a dict, you can use the `_asdict`
    method:

    >>> d = user._asdict()
    >>> d['username']
    'admin'

    Python 3 Notes
    ==============

    Because the unicode support in Python 3 no longer transparently
    handles bytes and unicode objects we had to change the way the
    decoding works.  On Python 3 you most likely want to always
    decode strings.  Because this would totally fail on binary data
    phpserialize uses the "surrogateescape" method to not fail on
    invalid data.  See the documentation in Python 3 for more
    information.

    Changelog
    =========

    1.3
        -   added support for Python 3

    1.2
        -   added support for object serialization
        -   added support for array hooks

    1.1
        -   added `dict_to_list` and `dict_to_tuple`
        -   added support for unicode
        -   allowed chaining of objects like pickle does


    :copyright: 2007-2012 by Armin Ronacher.
    license: BSD
�N�surrogateescape�strict)�StringIO)�BytesIOz,Armin Ronacher <armin.ronacher@active-4.com>z1.3)
�	phpobject�convert_member_dict�dict_to_list�
dict_to_tuple�load�loads�dump�dumps�	serialize�unserializec�Z�|dd�dkr|�dd��d}|S)N�� ����)�split)�names �l/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/phpserialize.py�_translate_member_namer#s0���B�Q�B�x�3����z�z�$��"�"�2�&���K�c�<�eZdZdZdZd
d�Zd�Zd�Zd�Zd�Z	d	�Z
dS)rz5Simple representation for PHP objects.  This is used )�__name__�__php_vars__Nc�~�|�i}t�|d|��t�|d|��dS)Nrr)�object�__setattr__)�selfr�ds   r�__init__zphpobject.__init__-sB���9��A����4��T�2�2�2����4���3�3�3�3�3rc�*�t|j��S)z?Returns a new dictionary from the data with Python identifiers.)rr�r!s r�_asdictzphpobject._asdict3s��"�4�#4�5�5�5rc�v�|j���D]\}}t|��|kr||fcS�dS�N)r�itemsr)r!r�key�values    r�_lookup_php_varzphpobject._lookup_php_var7sV���+�1�1�3�3�	"�	"�J�C��%�c�*�*�d�2�2��E�z�!�!�!�3�	"�	"rc�^�|�|��}|�|dSt|���)Nr)r,�AttributeError)r!r�rvs   r�__getattr__zphpobject.__getattr__<s1��
�
!�
!�$�
'�
'��
�>��a�5�L��T�"�"�"rc�X�|�|��}|�|d}||j|<dS)Nr)r,r)r!rr+r/s    rr zphpobject.__setattr__Bs6��
�
!�
!�$�
'�
'��
�>��a�5�D�"'���$���rc��d|j�d�S)Nz<phpobject �>)rr%s r�__repr__zphpobject.__repr__Hs���#'�=�=�=�2�2rr()r�
__module__�__qualname__�__doc__�	__slots__r#r&r,r0r r4�rrrr)s~������?�?�,�I�4�4�4�4�6�6�6�"�"�"�
#�#�#�(�(�(�3�3�3�3�3rrc�X�td�|���D����S)a�Converts the names of a member dict to Python syntax.  PHP class data
    member names are not the plain identifiers but might be prefixed by the
    class name if private or a star if protected.  This function converts them
    into standard Python identifiers:

    >>> convert_member_dict({"username": "user1", " User password":
    ...                      "default", " * is_active": True})
    {'username': 'user1', 'password': 'default', 'is_active': True}
    c3�>K�|]\}}t|��|fV��dSr()r)�.0�k�vs   r�	<genexpr>z&convert_member_dict.<locals>.<genexpr>Vs4����E�E�4�1�a�'��*�*�A�.�E�E�E�E�E�Er)�dictr)�r"s rrrLs)���E�E�1�7�7�9�9�E�E�E�E�E�Erzutf-8c�2���������fd���|d��S)z�Return the PHP-serialized representation of the object as a string,
    instead of writing it to a file like `dump` does.  On Python 3
    this returns bytes objects, on Python 3 this returns bytestrings.
    c����|�r]t|ttttf��rd|z�d��St|t��r�|}t|t��r|��	�
��}t��}|�	d��|�	tt|�����d����|�	d��|�	|��|�	d��|���S|�dStdt|��z���|�dSt|t��rd	|z�d��St|ttf��rd
|z�d��St|t��rd|z�d��St|t��r�|}t|t��r|��	�
��}t��}|�	d��|�	tt|�����d����|�	d��|�	|��|�	d��|���St|tt t"f��r�g}t|t"��r|���}nt'|��}|D]C\}}|��|d����|��|d
�����Dd�dtt|�����d��dd�|��dg��St|t,��r6d�|jd��dd�z�|jd
��dd�zS����|��d
��Stdt|��z���)Nzi:%i;�latin1ss:s:"s";ss:0:"";zcan't serialize %r as keysN;zb:%i;zi:%s;zd:%s;TFrsa:s:{�}�Orrzcan't serialize %r)�
isinstance�int�long�float�bool�encode�
basestring�unicoder�write�str�len�getvalue�	TypeError�type�list�tupler@r)�	enumerate�append�joinrrr)�obj�keypos�encoded_obj�s�out�iterabler*r+�
_serialize�charset�errors�object_hooks        ����rr`zdumps.<locals>._serialize^s�����:	?��#��T�5�$�7�8�8�
8��#�
�-�-�h�7�7�7��#�z�*�*�

$�!���c�7�+�+�>�"%�*�*�W�f�"=�"=�K��I�I�������������C��,�,�-�-�4�4�X�>�>�?�?�?������������$�$�$���������z�z�|�|�#��{�!�z��8�4��9�9�D�E�E�E��{��u��#�t�$�$�
8��#�
�-�-�h�7�7�7��#��T�{�+�+�
8��#�
�-�-�h�7�7�7��#�u�%�%�
8��#�
�-�-�h�7�7�7��#�z�*�*�

$�!���c�7�+�+�>�"%�*�*�W�f�"=�"=�K��I�I�������������C��,�,�-�-�4�4�X�>�>�?�?�?������������$�$�$���������z�z�|�|�#��#��e�T�2�3�3�
����c�4�(�(�.�"�y�y�{�{�H�H�(��~�~�H�"*�9�9�J�C���J�J�z�z�#�t�4�4�5�5�5��J�J�z�z�%��7�7�8�8�8�8��x�x����C���M�M�(�(��2�2���H�H�S�M�M��!�����#�y�)�)�
?��j�j���t�<�<�Q�r�T�B�B�!�z�#�"2�E�:�:�1�2�2�>�?�?��&�!�z�+�+�c�"2�"2�E�:�:�:��1�D��I�I�=�>�>�>rFr9)�datararbrcr`s ```@rrrYsC������
;?�;?�;?�;?�;?�;?�;?�;?�z�:�d�E�"�"�"rFc	�x����������	���t��fd���fd�����	fd�����������f	d��	�	��S)a\Read a string from the open file object `fp` and interpret it as a
    data stream of PHP-serialized objects, reconstructing and returning
    the original object hierarchy.

    `fp` must provide a `read()` method that takes an integer argument.  Both
    method should return strings.  Thus `fp` can be a file object opened for
    reading, a `StringIO` object (`BytesIO` on Python 3), or any other custom
    object that meets this interface.

    `load` will read exactly one object from the stream.  See the docstring of
    the module for this chained behavior.

    If an object hook is given object-opcodes are supported in the serilization
    format.  The function is called with the class name and a dict of the
    class data members.  The data member names are in PHP format which is
    usually not what you want.  The `simple_object_hook` function can convert
    them to Python identifier names.

    If an `array_hook` is given that function is called with a list of pairs
    for all array items.  This can for example be set to
    `collections.OrderedDict` for an ordered, hashed dictionary.
    Nc�����t|����}||krtd|�d|�����dS)Nzfailed expectation, expected z got )�readrQ�
ValueError)�er>�fps  �r�_expectzload.<locals>._expect�sC����G�G�C��F�F�O�O����6�6��*����A�A�N�O�O�O��6rc���g}	��d��}||krn'|std���|�|���Cd�|��S)Nrzunexpected end of streamr)rgrhrXrY)�delim�buf�charrjs   �r�_read_untilzload.<locals>._read_until�sh�����	��7�7�1�:�:�D��u�}�}���
=� �!;�<�<�<��J�J�t����
	��x�x��}�}�rc���t�d����dz}�d��g}t}t|��D]6}���}|tur|}�|�||f��t}�7�d��|S)N�:r�{rE)rH�Ellipsis�xrangerX)r)�result�	last_item�idx�itemrkrp�_unserializes     ���r�_load_arrayzload.<locals>._load_array�s�����K�K��%�%�&�&��*�����
�
�
����	��%�=�=�	%�	%�C��<�>�>�D��H�$�$� �	�	��
�
�y�$�/�0�0�0�$�	�	����
�
�
��
rc��	���d�����}|dkr
�d��dS|dvrS�d���d��}|dkrt|��S|dkrt|��St|��dkS|d	krs�d��t�d����}�d
����|��}�d
���
r|��	���}�d��|S|dkr�d��������S|dkr��
�td
����d��t�d����}�d
����|��}�d���
r|��	���}�
|t
�������Std���)Nr�n�;sidbrr�i�dr�s�"�a�oz7object in serialization dump but object_hook not given.s":zunexpected opcode)rg�lowerrHrJ�decoderhr@)�type_rd�length�name_lengthrrkr{rp�
array_hookra�decode_stringsrbrjrcs     ���������rrzzload.<locals>._unserialize�s�������
�
� � �"�"���D�=�=��G�D�M�M�M��4��F�?�?��G�D�M�M�M��;�t�$�$�D���}�}��4�y�y� ���}�}��T�{�{�"��t�9�9��>�!��D�=�=��G�D�M�M�M����T�*�*�+�+�F��G�D�M�M�M��7�7�6�?�?�D��G�D�M�M�M��
4��{�{�7�F�3�3���G�D�M�M�M��K��D�=�=��G�D�M�M�M��:�k�k�m�m�,�,�,��D�=�=��"� �":�;�;�;��G�D�M�M�M��k�k�$�/�/�0�0�K��G�D�M�M�M��7�7�;�'�'�D��G�E�N�N�N��
4��{�{�7�F�3�3���;�t�T�+�+�-�-�%8�%8�9�9�9��,�-�-�-r)r@)
rjrarbr�rcr�rkr{rprzs
``````@@@@rrr�s�������������0���
�P�P�P�P�P�
	�	�	�	�	�
�
�
�
�
�
�
�&.�&.�&.�&.�&.�&.�&.�&.�&.�&.�&.�&.�&.�P�<�>�>�rc�D�tt|��|||||��S)z�Read a PHP-serialized object hierarchy from a string.  Characters in the
    string past the object's representation are ignored.  On Python 3 the
    string must be a bytestring.
    )rr)rdrarbr�rcr�s      rrrs)�����
�
�w����Z�)�)�)rc�P�|�t||||����dS)akWrite a PHP-serialized representation of obj to the open file object
    `fp`.  Unicode strings are encoded to `charset` with the error handling
    of `errors`.

    `fp` must have a `write()` method that accepts a single string argument.
    It can thus be a file object opened for writing, a `StringIO` object
    (or a `BytesIO` object on Python 3), or any other custom object that meets
    this interface.

    The `object_hook` is called for each unknown object and has to either
    raise an exception if it's unable to convert the object or return a
    value that is serializable (such as a `phpobject`).
    N)rOr)rdrjrarbrcs     rr
r

s*���H�H�U�4��&�+�
6�
6�7�7�7�7�7rc���t����	�fd�tt�����D��S#t$rt	d���wxYw)z%Converts an ordered dict into a list.c� ��g|]
}�|��Sr9r9)r<�xr"s  �r�
<listcomp>z dict_to_list.<locals>.<listcomp>$s���-�-�-���!��-�-�-rzdict is not a sequence)r@rurQ�KeyErrorrhrAs`rr	r	se���	
�Q���A�3�-�-�-�-�f�S��V�V�n�n�-�-�-�-���3�3�3��1�2�2�2�3���s	�':�Ac�:�tt|����S)z&Converts an ordered dict into a tuple.)rVr	rAs rr
r
)s����a���!�!�!r)!r7�codecs�lookup_error�default_errors�LookupErrorrr�ImportError�iorN�	NameErrorrP�bytesrMrIrHru�range�
__author__�__version__�__all__rrrrrrrr
r	r
rrr9rr�<module>r�s]��|�|�z�
�
�
���F��)�*�*�*�&�N�N�������N�N�N�����&�,�,�,�,�,�,�,���&�&�&�%�%�%�%�%�%�%�%�&������G�G�������G����J�J�J�����
��D�D�������D�D�D������
�F�F������
�F�F�F�����<�
���I����� 3� 3� 3� 3� 3�� 3� 3� 3�F
F�
F�
F� ��D�B#�B#�B#�B#�J�^�E��d�b�b�b�b�J ��u��t�)�)�)�)�#�>�t�8�8�8�8�"3�3�3�"�"�"�

�	����sN��%�%�0�>�>�A�A�A�A�A$�#A$�(A+�+A5�4A5