Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/http/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/http/__pycache__/cookiejar.cpython-311.pyc

�

�܋f?+��l�dZddlmZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZddlm
Z
mZgd�Zdd	lZdd	lZdd	lZerde_dd	lZdd
lmZmZmZddlmZ	dd	lZn#e$rdd	lZYnwxYwddlm Z d
Z!d	a"d�Z#ee��Z$dZ%d�Z&dZ'd�Z(gd�Z)gd�Z*gZ+e*D])Z,e+�-e,�.�����*dPd�Z/dPd�Z0d	d	d	d	d�Z1ej2dej��Z3d�Z4d�Z5ej2dej��Z6ej2dej7ejz��Z8ej2dej9ejz��Z:d�Z;ej2dej9ejz��Z<d �Z=d!�Z>ej2d"��Z?ej2d#��Z@ej2d$��ZAej2d%��ZBd&�ZCej2d'��ZDd(�ZEd)�ZFd*�ZGej2d+ej��ZHd,�ZId-�ZJd.�ZKd/�ZLej2d0ej��ZMd1�ZNd2�ZOd3�ZPd4�ZQd5ZRej2d6��ZSd7�ZTd8�ZUd9�ZVd:�ZWGd;�d<eX��ZYGd=�d>eX��ZZGd?�d@eZ��Z[dA�Z\dB�Z]GdC�dDeX��Z^GdE�dFeX��Z_GdG�dHe`��ZaGdI�dJe_��ZbdK�ZcGdL�dMeb��ZdGdN�dOeb��Zed	S)Qa�HTTP cookie handling for web clients.

This is a backport of the Py3.3 ``http.cookiejar`` module for
python-future.

This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.

Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):

                        CookieJar____
                        /     \      \
            FileCookieJar      \      \
             /    |   \         \      \
 MozillaCookieJar | LWPCookieJar \      \
                  |               |      \
                  |   ---MSIEBase |       \
                  |  /      |     |        \
                  | /   MSIEDBCookieJar BSDDBCookieJar
                  |/
               MSIECookieJar

�)�unicode_literals)�print_function)�division)�absolute_import)�filter�int�map�open�str)�
as_native_str�PY2)�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJarN)�urlparse�urlsplit�quote)�	HTTP_PORT)�timegmFc�p�tsdStsddl}|�d��atj|�S)Nrzhttp.cookiejar)�debug�logger�logging�	getLogger)�argsrs  �p/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/backports/http/cookiejar.py�_debugr":sA�������5������"�"�#3�4�4���<����zQa filename was not supplied (nor was the CookieJar instance initialised with one)c���ddl}ddl}ddl}|���}|�d|��|���}|�d|zd���dS)Nrzhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)r'r(r)�f�msgs     r!�_warn_unhandled_exceptionr0Hsz��#�"�"�"�"�"�"�"�"�"�"�"�
���
�
�A�
����a� � � �
�*�*�,�,�C��M�M�+�c�1�a�M�@�@�@�@�@r#i�c��|dd�\}}}}}}|tkr_d|cxkrdkrRnnOd|cxkrdkrBnn?d|cxkrdkr2nn/d|cxkrdkr"nnd|cxkrdkrnnt|��SdS)	N����r��;�=)�
EPOCH_YEARr)�tt�year�month�mday�hour�min�secs       r!�_timegmrAWs���(*�2�A�2��%�D�%��t�S�#�	
��	�	�!�u�"2�"2�"2�"2��"2�"2�"2�"2�"2��d�����b������	
�d�����b������q�C�~�~�~�~�2�~�~�~�~�~�A��N�N�N�N��N�N�N�N�N��b�z�z���tr#)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc���|�tj���}ntj�|��}d|j|j|j|j|j|jfzS)aHReturn a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
    representing Universal Time (UTC, aka GMT).  An example of this format is:

    1994-11-24 08:49:37Z

    Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr;r<�dayr>�minute�second��t�dts  r!�	time2isozr_esc��	�y�
�
�
%�
%�
'�
'���
�
�
/�
/��
2�
2��+�
����2�6�2�7�B�I�r�y�/B�B�Br#c�,�|�tj���}ntj�|��}dt|���|jt|jdz
|j|j	|j
|jfzS)z�Return a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like this:

    Wed, DD-Mon-YYYY HH:MM:SS GMT

    Nz"%s %02d-%s-%04d %02d:%02d:%02d GMTr3)rVrWrX�DAYS�weekdayrY�MONTHSr<r;r>rZr[r\s  r!�
time2netscaperdxsy��	�y�
�
�
%�
%�
'�
'���
�
�
/�
/��
2�
2��/��R�Z�Z�\�\��B�F�F�2�8�A�:�$6�
����"�)�R�Y�30�0�0r#)�GMT�UTC�UT�Zz^([-+])?(\d\d?):?(\d\d)?$c�V�d}|tvrd}n�t�|��}|r~dt|�d����z}|�d��r(|dt|�d����zz}|�d��dkr|}|S)Nrir%��<r3�-)�	UTC_ZONES�TIMEZONE_RE�searchr�group)�tz�offset�ms   r!�offset_from_tz_stringrt�s���
�F�	�Y���������r�"�"���	!��C�����
�
�O�O�+�F��w�w�q�z�z�
7��"�s�1�7�7�1�:�:���"6�6���w�w�q�z�z�S� � � ����Mr#c	�
�	t�|�����dz}nI#t$r<	t	|��}n#t$rYYdSwxYwd|cxkrdkrnn|}nYdSYnwxYw|�d}|�d}|�d}t	|��}t	|��}t	|��}t	|��}t	|��}|dkrctjtj����d}|dz}	|}
||z|	z
}|	|
z
}	t|	��dkr|	dkr|dz}n|dz
}t|||||||f��}|�0|�d}|�	��}t|��}|�dS||z
}|S)Nr3r4ri��d�2rf)�MONTHS_LOWER�index�lower�
ValueErrorr�time�	localtime�absrA�upperrt)
rY�mon�yr�hrr?r@rq�imon�cur_yrrs�tmpr]rrs
             r!�	_str2timer��s����� � ������-�-�a�/�����	�	�	�	��s�8�8�D�D���	�	�	��4�4�4�	������?�?�?�?��?�?�?�?�?��C�C��4�4�
�C�	����
�z��2�
�{�!�C�
�{�!�C�	�R���B�

�c�(�(�C�	�R���B�

�c�(�(�C�

�c�(�(�C�	�D�y�y����	���,�,�Q�/���S�L����
�&�[�1�_��
��G���q�6�6�B�;�;��1�u�u�2��8�b�b��C�x�"�	��S�#�r�3��R�0�1�1�A��}�
�:��B�
�X�X�Z�Z��&�r�*�*���>��4�
��J���Hs2�/2�
A8�A
�A8�
A�A8�A�A8�7A8zV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    (?:
       ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
       \s*
    )?
    (?:
       \(\w+\)         # ASCII representation of timezone in parens.
       \s*
    )?$c	���t�|��}|r�|���}t�|d�����dz}t
|d��|t
|d��t
|d��t
|d��t|d��f}t|��S|�	��}t�d|d��}dgd	z\}}}}}}	}
t�|��}|�|���\}}}}}}	}
ndSt||||||	|
��S)
a�Returns time in seconds since epoch of time represented by a string.

    Return value is an integer.

    None is returned if the format of str is unrecognized, the time is outside
    the representable range, or the timezone string is not recognized.  If the
    string contains no timezone, UTC is assumed.

    The timezone in the string may be numerical (like "-0800" or "+0100") or a
    string timezone (like "UTC", "GMT", "BST" or "EST").  Currently, only the
    timezone strings equivalent to UTC (zero offset) are known to the function.

    The function loosely parses the following formats:

    Wed, 09 Feb 1994 22:23:32 GMT       -- HTTP format
    Tuesday, 08-Feb-94 14:15:29 GMT     -- old rfc850 HTTP format
    Tuesday, 08-Feb-1994 14:15:29 GMT   -- broken rfc850 HTTP format
    09 Feb 1994 22:23:32 GMT            -- HTTP format (no weekday)
    08-Feb-94 14:15:29 GMT              -- rfc850 format (no weekday)
    08-Feb-1994 14:15:29 GMT            -- broken rfc850 format (no weekday)

    The parser ignores leading and trailing whitespace.  The time may be
    absent.

    If the year is given with only 2 digits, the function will select the
    century that makes the year closest to the current date.

    r3r%rrj���N�)�STRICT_DATE_REro�groupsrxryrzr�floatrA�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_REr�)�textrs�gr�r:rYr�r�r?r@rqs           r!�	http2timer��s:��<	���d�#�#�A���
�H�H�J�J��� � ��1������.�.��2���!�A�$�i�i��c�!�A�$�i�i��!�A�$�i�i��Q�q�T���E�!�A�$�K�K�1���r�{�{��
�;�;�=�=�D��>�>�"�d�A�&�&�D�'+�V�A�X�"�C��b�"�c�3��	�!�!�$�'�'�A��}�)*�����&��S�"�b�#�s�B�B��t��S�#�r�2�s�C��4�4�4r#a�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   (?:
      ([-+]?\d\d?:?(:?\d\d)?
       |Z|z)             # timezone  (Z is "zero meridian", i.e. GMT)
      \s*
   )?$c	���|���}dgdz\}}}}}}}t�|��}|�|���\}}}}}}}}	ndSt	|||||||��S)av
    As for http2time, but parses the ISO 8601 formats:

    1994-02-03 14:15:29 -0100    -- ISO 8601 format
    1994-02-03 14:15:29          -- zone is optional
    1994-02-03                   -- only date
    1994-02-03T14:15:29          -- Use T as separator
    19940203T141529Z             -- ISO 8601 compact format
    19940203                     -- only date

    Nr�)r��ISO_DATE_REror�r�)
r�rYr�r�r�r?r@rqrs�_s
          r!�iso2timer�6s����;�;�=�=�D�'+�V�A�X�"�C��b�"�c�3��	���4� � �A��}�-.�H�H�J�J�)��C��b�#�s�B����t��S�#�r�2�s�C��4�4�4r#c�p�|�d��\}}|jd|�|j|d�zS)z)Return unmatched part of re.Match object.rN)�span�string)�match�start�ends   r!�	unmatchedr�Ws6�����A���J�E�3��<�������S�T�T� 2�2�2r#z^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c��t|t��rJ�g}|D�]�}|}g}|�r�t�|��}|r�t	|��}|�d��}t�|��}|r@t	|��}|�d��}t�d|��}nWt�|��}|r9t	|��}|�d��}|�
��}nd}|�||f��n�|����
d��r6|���dd�}|r|�|��g}n4tjdd|��\}}	|	dksJd|�d	|�d
|�����|}|���|r|�|�����|S)amParse header values into a list of lists containing key,value pairs.

    The function knows how to deal with ",", ";" and "=" as well as quoted
    values after "=".  A list of space separated tokens are parsed as if they
    were separated by ";".

    If the header_values passed as argument contains multiple values, then they
    are treated as if they were a single value separated by comma ",".

    This means that this function is useful for parsing header fields that
    follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
    the requirement for tokens).

      headers           = #header
      header            = (token | parameter) *( [";"] (token | parameter))

      token             = 1*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    r3z\1N�,z^[=\s;]*r�rzsplit_header_words bug: 'z', 'z', )�
isinstancer�HEADER_TOKEN_REror�rp�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr��HEADER_VALUE_RE�rstrip�appendr��
startswith�re�subn)
�
header_values�resultr��	orig_text�pairsrs�name�value�non_junk�
nr_junk_charss
          r!�split_header_wordsr�`s���Z�-��-�-�-�-�-�
�F��#'�#'���	����	 ��&�&�t�,�,�A��
 � ��|�|���w�w�q�z�z��*�1�1�$�7�7���%�$�Q�<�<�D��G�G�A�J�J�E�,�0�0���>�>�E�E�'�.�.�t�4�4�A��%�(��|�|�� !����
�
�� %�������!%�����d�E�]�+�+�+�+������)�)�#�.�.�
 ��{�{�}�}�Q�R�R�(���.�&�-�-��.�.�.����+-�'�*�b�$�*G�*G�'��-�$�q�(�(�(�(��Y�Y����e�e�-�)�(�(� ��?�	 �@�&�&�-�-��&�&�&���Mr#�([\"\\])c�H�g}|D]�}g}|D]X\}}|�<tjd|��s t�d|��}d|z}|�d|��}|�|���Y|r(|�d�|������d�|��S)a�Do the inverse (almost) of the conversion done by split_header_words.

    Takes a list of lists of (key, value) pairs and produces a single header
    value.  Attribute values are quoted if needed.

    >>> join_header_words([[("text/plain", None), ("charset", "iso-8859/1")]])
    'text/plain; charset="iso-8859/1"'
    >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859/1")]])
    'text/plain, charset="iso-8859/1"'

    Nz^\w+$�\\\1z"%s"�=�; �, )r�ro�HEADER_JOIN_ESCAPE_REr�r��join)�lists�headersr��attr�k�vs      r!�join_header_wordsr��s����G��	1�	1�����	�	�D�A�q��}��y��1�-�-�#�-�1�1�'�1�=�=�A���
�A� �q�q�!�!�$���K�K��N�N�N�N��0�����	�	�$���0�0�0���9�9�W���r#c��|�d��r
|dd�}|�d��r
|dd�}|S)N�"r3���)r��endswith�r�s r!�strip_quotesr��sI�����s�����A�B�B�x���}�}�S�����C�R�C�y���Kr#c�R�d}g}|D�]}g}d}ttjd|����D]�\}}|���}|dkr� d|vr|d}	}n-tjd|d��\}}	|���}|d	krS|���}
|
|vr|
}|d
krt
|	��}	d}|dkrtt
|	����}	|�||	f����|r,|s|�d
��|�|���� |S)a5Ad-hoc parser for Netscape protocol cookie-attributes.

    The old Netscape cookie format for Set-Cookie can for instance contain
    an unquoted "," in the expires field, so we have to use this ad-hoc
    parser instead of split_header_words.

    XXX This may not make the best possible effort to parse all the crap
    that Netscape Cookie headers contain.  Ronald Tschalar's HTTPClient
    parser is probably better, so could do worse than following that if
    this ever gives any trouble.

    Currently, this is also used for parsing RFC 2109 cookies.

    )�expires�domain�path�secure�version�port�max-ageFz;\s*r�r�Nz\s*=\s*r3rr�Tr�)r��0)	�	enumerater��splitr�r�rzr�r�r�)�
ns_headers�known_attrsr��	ns_headerr��version_set�ii�paramr�r��lcs           r!�parse_ns_headersr��sQ��1�K��F��!�!�	�����"�2�8�G�Y�#?�#?�@�@�	!�	!�I�B���L�L�N�N�E���{�{�H��%����d�1����x�
�E�1�5�5���1��H�H�J�J���Q�w�w��W�W�Y�Y����$�$��A��	�>�>�$�Q���A�"&�K��	�>�>�!�,�q�/�/�2�2�A��L�L�!�Q�� � � � ��	!��
/����-�.�.�.��M�M�%� � � ���Mr#z\.\d+$c��t�|��rdS|dkrdS|ddks|ddkrdSdS)z*Return True if text is a host domain name.Fr�r�.r�T��IPV4_REror�s r!�is_HDNr�sN���~�~�d�����u��r�z�z��u��A�w�#�~�~��b��S����u��4r#c�.�|���}|���}||krdSt|��sdS|�|��}|dks|dkrdS|�d��sdSt|dd���sdSdS)a�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    TFr�rr�r3N)rzr��rfindr�)�A�B�is   r!�domain_matchr�s���.	
���	�	�A�	���	�	�A��A�v�v��t��!�9�9���u�	����
�
�A��B�w�w�!�q�&�&��u��<�<������u��!�A�B�B�%�=�=���u��4r#c�>�t�|��rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FTr�r�s r!�liberal_is_HDNr�As"���~�~�d�����u��4r#c��|���}|���}t|��rt|��s
||krdSdS|�d��}|r|�|��rdS|s||krdSdS)z\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    TFr�)rzr�r�r�)r�r��initial_dots   r!�user_domain_matchr�Ks���	
���	�	�A�	���	�	�A��1����.��"3�"3����6�6��4��u��,�,�s�#�#�K���q�z�z�!�}�}���t���1��6�6��t��5r#z:\d+$c���|���}t|��d}|dkr|�dd��}t�d|d��}|���S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    r3r��Host)�get_full_urlr�
get_header�cut_port_rer�rz)�request�url�hosts   r!�request_hostr�`sh���
�
�
 �
 �C��C�=�=���D��r�z�z��!�!�&�"�-�-���?�?�2�t�Q�'�'�D��:�:�<�<�r#c��t|��x}}|�d��dkrt�|��s|dz}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    r�r��.local)r��findr�ro)r��erhn�req_hosts   r!�eff_request_hostr�psR��#�7�+�+�+�D�8��}�}�S���R������x�(@�(@���(�"���T�>�r#c��|���}t|��}t|j��}|�d��sd|z}|S)z6Path component of request-URI, as defined by RFC 2965.�/)r�r�escape_pathr�r�)r�r��partsr�s    r!�request_pathr{sO��
�
�
�
 �
 �C��S�M�M�E��u�z�"�"�D��?�?�3�����T�z���Kr#c���|j}|�d��}|dkr?||dzd�}	t|��n(#t$rt	d|��YdSwxYwt
}|S)N�:rr3znonnumeric port: '%s')r�r�rr{r"�DEFAULT_HTTP_PORT)r�r�r�r�s    r!�request_portr�s����<�D��	�	�#���A��A�v�v��A�a�C�D�D�z��	���I�I�I�I���	�	�	��*�D�1�1�1��4�4�	����!���Ks�A�A�Az%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])c�V�d|�d�����zS)Nz%%%sr3)rpr)r�s r!�uppercase_escaped_charr�s#���E�K�K��N�N�(�(�*�*�*�*r#c�p�t|t��}t�t|��}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r�HTTP_PATH_SAFE�ESCAPED_CHAR_REr�r)r�s r!r�r��s.����~�&�&�D����5�t�<�<�D��Kr#c��|�d��}|dkrB||dzd�}|�d��}t|��r|dks|dkrd|zS|S)aBReturn reach of host h, as defined by RFC 2965, section 1.

    The reach R of a host name H is defined as follows:

       *  If

          -  H is the host domain name of a host; and,

          -  H has the form A.B; and

          -  A has no embedded (that is, interior) dots; and

          -  B has at least one embedded dot, or B is the string "local".
             then the reach of H is .B.

       *  Otherwise, the reach of H is H.

    >>> reach("www.acme.com")
    '.acme.com'
    >>> reach("acme.com")
    'acme.com'
    >>> reach("acme.local")
    '.local'

    r�rr3N�local)r�r�)�hr��bs   r!�reachr�sh��4	
���s���A��A�v�v�
�a��c�d�d�G��
�F�F�3�K�K���!�9�9�	�!�q�&�&�A��L�L��q�5�L��Hr#c��t|��}t|t|�������sdSdS)z�

    RFC 2965, section 3.3.6:

        An unverifiable transaction is to a third-party host if its request-
        host U does not domain-match the reach R of the request-host O in the
        origin transaction.

    TF)r�r�r�get_origin_req_host)r�r�s  r!�is_third_partyr�sA���G�$�$�H���%��(C�(C�(E�(E�"F�"F�G�G���t��ur#c�d�eZdZdZ	dd�Zd�Zdd�Zd�Zdd�Zd	�Z	e
��d
���ZdS)
ra�HTTP Cookie.

    This class represents both Netscape and RFC 2965 cookies.

    This is deliberately a very simple class.  It just holds attributes.  It's
    possible to construct Cookie instances that don't comply with the cookie
    standards.  CookieJar.make_cookies is the factory function for Cookie
    objects -- it deals with cookie parsing, supplying defaults, and
    normalising to the representation used in this class.  CookiePolicy is
    responsible for checking them to see whether they should be accepted from
    and returned to the server.

    Note that the port may be present in the headers, but unspecified ("Port"
    rather than"Port=80", for example); if this is the case, port is None.

    Fc��|�t|��}|�t|��}|�|durtd���||_||_||_||_||_|���|_||_	||_
|	|_|
|_||_
||_|
|_||_||_||_t'j|��|_dS)NTz-if port is None, port_specified must be false)rr{r�r�r�r��port_specifiedrzr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�r�r�r�rr�rrr�rr�r�rrr�restrs                  r!�__init__zCookie.__init__�s�����#�g�,�,����#�g�,�,���<�N�d�2�2��L�M�M�M������	���
���	�,����l�l�n�n��� 0���
#5�����	�,���������������&�������Y�t�_�_��
�
�
r#c��||jvS�N�r)rr�s  r!�has_nonstandard_attrzCookie.has_nonstandard_attrs���t�z�!�!r#Nc�8�|j�||��Sr")r�get)rr��defaults   r!�get_nonstandard_attrzCookie.get_nonstandard_attrs���z�~�~�d�G�,�,�,r#c��||j|<dSr"r#)rr�r�s   r!�set_nonstandard_attrzCookie.set_nonstandard_attrs�� ��
�4���r#c�X�|�tj��}|j�
|j|krdSdS�NTF)r|r�)r�nows  r!�
is_expiredzCookie.is_expireds/���;�d�i�k�k���L�$�4�<�3�+>�+>��4��ur#c��|j�d}n
d|jz}|j|z|jz}|j�|j�d|j��}n|j}d|�d|�d�S)Nr�rr�z<Cookie z for �>)r�r�r�r�r�)r�p�limit�	namevalues    r!�__str__zCookie.__str__$sf���9��"�a�a��d�i�-�a���a��$�)�+���:�!�#'�9�9�9�d�j�j�9�I�I��	�I��'0�y�y�%�%�%�8�8r#c��g}dD]j}t||��}t|t��rt|��}|�td��|t	|��fz���k|�dt	|j��z��|�dt	|j��z��dd�|��zS)N)r�r�r�r�rr�rrr�rr�r�rrrz%s=%szrest=%sz
rfc2109=%sz
Cookie(%s)r�)�getattrr�rr��reprrrr�)rr r�r�s    r!�__repr__zCookie.__repr__.s������	;�	;�D��4��&�&�D��$��$�$�
!��4�y�y���K�K��G����d�4�j�j�'9�9�:�:�:�:����I��T�Z� 0� 0�0�1�1�1����L�4���#5�#5�5�6�6�6��d�i�i��o�o�-�-r#)Fr")�__name__�
__module__�__qualname__�__doc__r r$r(r*r.r4rr8�r#r!rr�s���������6�(%�(%�(%�(%�T"�"�"�-�-�-�-�!�!�!�����9�9�9��]�_�_�.�.��_�.�.�.r#rc�*�eZdZdZd�Zd�Zd�Zd�ZdS)ra Defines which cookies get accepted from and returned to server.

    May also modify cookies, though this is probably a bad idea.

    The subclass DefaultCookiePolicy defines the standard rules for Netscape
    and RFC 2965 cookies -- override that if you want a customised policy.

    c��t���)z�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        ��NotImplementedError�r�cookier�s   r!�set_okzCookiePolicy.set_okLs��"�#�#�#r#c��t���)zAReturn true if (and only if) cookie should be returned to server.r@rBs   r!�	return_okzCookiePolicy.return_okU���!�#�#�#r#c��dS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr=)rr�r�s   r!�domain_return_okzCookiePolicy.domain_return_okY�	���tr#c��dS)zKReturn false if cookies should not be returned, given cookie path.
        Tr=)rr�r�s   r!�path_return_okzCookiePolicy.path_return_ok^rJr#N)r9r:r;r<rDrFrIrLr=r#r!rrCsZ��������$�$�$�$�$�$����
����r#rc���eZdZdZdZdZdZdZeezZdddddddddeddfd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS) rzBImplements the standard rules for accepting and returning cookies.r3r%r�rNTFc
��||_||_||_||_||_||_|	|_|
|_||_||_	|�t|��|_nd|_|�t|��}||_dS)zAConstructor arguments should be passed as keyword arguments only.Nr=)
�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�tuple�_blocked_domains�_allowed_domains)
r�blocked_domains�allowed_domainsrOrPrQrRrSrTrUrVrWrXs
             r!r zDefaultCookiePolicy.__init__ns���!��
����#6�� �(���*���+F��(�&<��#� 0���,H��)�"4����&�$)�/�$:�$:�D�!�!�$&�D�!��&�#�O�4�4�O� /����r#c��|jS)z4Return the sequence of blocked domains (as a tuple).)rZ�rs r!r\z#DefaultCookiePolicy.blocked_domains�����$�$r#c�.�t|��|_dS)z$Set the sequence of blocked domains.N)rYrZ)rr\s  r!�set_blocked_domainsz'DefaultCookiePolicy.set_blocked_domains�s�� %�o� 6� 6����r#c�@�|jD]}t||��rdS�dSr,)rZr�)rr��blocked_domains   r!�
is_blockedzDefaultCookiePolicy.is_blocked�s7��"�3�	�	�N� ���8�8�
��t�t�
��ur#c��|jS)z=Return None, or the sequence of allowed domains (as a tuple).)r[r_s r!r]z#DefaultCookiePolicy.allowed_domains�r`r#c�6�|�t|��}||_dS)z-Set the sequence of allowed domains, or None.N)rYr[)rr]s  r!�set_allowed_domainsz'DefaultCookiePolicy.set_allowed_domains�s#���&�#�O�4�4�O� /����r#c�R�|j�dS|jD]}t||��rdS�dS)NFT)r[r�)rr��allowed_domains   r!�is_not_allowedz"DefaultCookiePolicy.is_not_allowed�sE��� �(��5�"�3�	�	�N� ���8�8�
��u�u�
��tr#c��td|j|j��|j�J�dD]&}d|z}t||��}|||��sdS�'dS)z�
        If you override .set_ok(), be sure to call this method.  If it returns
        false, so should your subclass (assuming your subclass wants to be more
        strict about which cookies to accept).

        � - checking cookie %s=%sN)r��
verifiabilityr�r�r�r��set_ok_FT�r"r�r�r6�rrCr��n�fn_name�fns      r!rDzDefaultCookiePolicy.set_ok�sw��	�)�6�;���E�E�E��{�&�&�&�M�	�	�A���k�G���w�'�'�B��2�f�g�&�&�
��u�u�
��tr#c���|j�td|j|j��dS|jdkr|jstd��dS|jdkr|jstd��dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr�$   RFC 2965 cookies are switched off�$   Netscape cookies are switched offT)r�r"r�r�rPrOrBs   r!�set_ok_versionz"DefaultCookiePolicy.set_ok_version�s����>�!�
�E��;���
.�
.�
.��5��>�A���d�l���9�:�:�:��5�
�^�q�
 �
 ���
 ��9�:�:�:��5��tr#c��|jrUt|��rF|jdkr|jrt	d��dS|jdkr|jrt	d��dSdS�Nrz>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT��unverifiablerr�rTr"rUrBs   r!�set_ok_verifiabilityz(DefaultCookiePolicy.set_ok_verifiability�s�����	�N�7�$;�$;�	��~��!�!�d�&F�!��8�9�9�9��u���1�$�$��)D�$��8�9�9�9��u��tr#c��|jdkr8|jr1|j�d��rt	d|j��dSdS)Nr�$z'   illegal name (starts with '$'): '%s'FT)r�rWr�r�r"rBs   r!�set_ok_namezDefaultCookiePolicy.set_ok_name�sN��
�N�a���D�$E���K�"�"�3�'�'�
 ��<�f�k�J�J�J��5��tr#c���|jr^t|��}|jdks|jdkr9|jr2|�|j��st
d|j|��dSdS)Nrz7   path attribute %s is not a prefix of request path %sFT)rrr�rXr�r�r")rrCr��req_paths    r!�set_ok_pathzDefaultCookiePolicy.set_ok_path�s|��� �	�#�G�,�,�H���!�#�#��.�A�%�%�$�*A�%��'�'���4�4�&��!�"(�+�x�9�9�9��u��tr#c�.�|�|j��rtd|j��dS|�|j��rtd|j��dS|j�r*t|��\}}|j}|jr�|�d��dkr�|�d��}|�dd|��}|dkrU||dzd�}||dz|�}	|	�	��dvr%t|��dkrtd	|��dS|�d��r|dd�}
n|}
|
�d��dk}|s|d
krtd|��dS|j
dkrU|�|��s@|�d��s+d|z�|��std||��dS|j
dks|j|jzr#t#||��std
||��dS|j
dks|j|jzr^|dt|���}|�d��dkr-t&�|��std||��dSdS)N�"   domain %s is in user block-listF�&   domain %s is not in user allow-listr�r%rr3)�co�ac�com�edu�org�net�gov�milr�aero�biz�cat�coop�info�jobs�mobi�museumr��pro�travel�euz&   country-code second level domain %sr�z/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rer�r"rkrr�rS�countr�rz�lenr�r�r�r�rV�DomainRFC2965Matchr��DomainStrictNoDotsr�ro)
rrCr�r�r�r�r��j�tld�sld�undotted_domain�
embedded_dots�host_prefixs
             r!�
set_ok_domainz!DefaultCookiePolicy.set_ok_domain�s����?�?�6�=�)�)�	��7���G�G�G��5����v�}�-�-�	��;�V�]�K�K�K��5��"�1	!�-�g�6�6�N�H�d��]�F��!�
%�v�|�|�C�'8�'8�A�'=�'=��L�L��%�%���L�L��a��+�+����6�6� ��1����,�C� ��1��Q��-�C��y�y�{�{�''�'�'�,/�s�8�8�q�=�=��G��P�P�P�$�u�� � ��%�%�
)�"(����*���"(��,�1�1�#�6�6�!�;�M� �
�V�x�%7�%7��H������u��~��"�"��
�
�f�-�-�!�����-�-�!��d�(�,�,�V�4�4�!��?���)�)�)�!�5����"�"��&��)@�@�#�#�D�&�1�1�!�� �!%�v�/�/�/� �5����"�"��&��)@�@�#�&�}��V����}�5���$�$�S�)�)�Q�.�.����x�0�0�/��K�&��0�0�0� �5��tr#c�:�|jr�t|��}|�d}nt|��}|j�d��D]=}	t|��n"#t$rtd|��YdSwxYw||krn�>td||j��dSdS)N�80r�z   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)rrrr�r�rr{r"�rrCr��req_portr1s     r!�set_ok_portzDefaultCookiePolicy.set_ok_port*s���� �	�#�G�,�,�H�������x�=�=���[�&�&�s�+�+�
�
��!���F�F�F�F��!�!�!�!��9�1�=�=�=� �5�5�5�!������=�=��E�!��=����.�.�.��u��ts�A�A7�6A7c��td|j|j��dD]&}d|z}t||��}|||��sdS�'dS)z�
        If you override .return_ok(), be sure to call this method.  If it
        returns false, so should your subclass (assuming your subclass wants to
        be more strict about which cookies to return).

        rm)r�rnr�r�r�r��
return_ok_FTrprqs      r!rFzDefaultCookiePolicy.return_ok?sg��	�)�6�;���E�E�E�R�	�	�A�"�1�n�G���w�'�'�B��2�f�g�&�&�
��u�u�
��tr#c��|jdkr|jstd��dS|jdkr|jstd��dSdS)NrrvFrwT)r�rPr"rOrBs   r!�return_ok_versionz%DefaultCookiePolicy.return_ok_versionQsW���>�A���d�l���9�:�:�:��5�
�^�q�
 �
 ���
 ��9�:�:�:��5��tr#c��|jrUt|��rF|jdkr|jrt	d��dS|jdkr|jrt	d��dSdSrzr{rBs   r!�return_ok_verifiabilityz+DefaultCookiePolicy.return_ok_verifiabilityZs�����	�N�7�$;�$;�	��~��!�!�d�&F�!��%�&�&�&��u���1�$�$��)D�$��%�&�&�&��u��tr#c�L�|jr|jdkrtd��dSdS)N�httpsz(   secure cookie with non-secure requestFT)r��typer"rBs   r!�return_ok_securez$DefaultCookiePolicy.return_ok_securefs1���=�	�W�\�W�4�4��=�>�>�>��5��tr#c�\�|�|j��rtd��dSdS)Nz   cookie expiredFT)r.�_nowr"rBs   r!�return_ok_expiresz%DefaultCookiePolicy.return_ok_expiresls3�����T�Y�'�'�	��&�'�'�'��5��tr#c��|jrPt|��}|�d}|j�d��D]
}||krn�td||j��dSdS)Nr�r�z0   request port %s does not match cookie port %sFT)r�rr�r"r�s     r!�return_ok_portz"DefaultCookiePolicy.return_ok_portrs~���;�
	�#�G�,�,�H������[�&�&�s�+�+�
�
����=�=��E�!��I����.�.�.��u��tr#c�p�t|��\}}|j}|jdkr-|j|jzr|js||krt
d��dS|jdkr#t||��st
d||��dS|jdkr+d|z�|��st
d||��dSdS)NrzQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sr�z;   request-host %s does not match Netscape cookie domain %sT)	r�r�r�rV�DomainStrictNonDomainrr"r�r�)rrCr�r�r�r�s      r!�return_ok_domainz$DefaultCookiePolicy.return_ok_domain�s���)�'�2�2���$����
�N�a���
�
"�T�%?�
?�
 ��'�
 �,2�d�N�N��-�
.�
.�
.��5��>�A���l�4��&@�&@���/�04�f�
>�
>�
>��5��>�Q����D��':�':�6�'B�'B����!�6�
+�
+�
+��5��tr#c��t|��\}}|�d��sd|z}|�d��sd|z}|�|��s|�|��sdS|�|��rt	d|��dS|�|��rt	d|��dSdS)Nr�Fr�r�T)r�r�r�rer"rk)rr�r�r�r�s     r!rIz$DefaultCookiePolicy.domain_return_ok�s���*�'�2�2���$��"�"�3�'�'�	$��8�|�H����s�#�#�	��t�8�D��!�!�&�)�)�	�T�]�]�6�-B�-B�	��5��?�?�6�"�"�	��7��@�@�@��5����v�&�&�	��;�V�D�D�D��5��tr#c��td|��t|��}|�|��std||��dSdS)Nz- checking cookie path=%sz  %s does not path-match %sFT)r"rr�)rr�r�r�s    r!rLz"DefaultCookiePolicy.path_return_ok�sS���*�D�1�1�1���(�(���"�"�4�(�(�	��0�(�D�A�A�A��5��tr#) r9r:r;r<r�r�r��
DomainLiberal�DomainStrictr r\rbrer]rhrkrDrxr}r�r�r�r�rFr�r�r�r�r�r�rIrLr=r#r!rrds�������L�L��������M�%�&;�;�L�"&�t���%)�#�$�-1�(-�"/�.3�$)�0�0�0�0�B%�%�%�7�7�7����%�%�%�0�0�0�������&
�
�
�
�
�
����	�	�	�9�9�9�v���*���$���
�
�
�������������,���,����r#rc�n�t|�����}t|j|��Sr")�sorted�keysr	r&)�adictr�s  r!�vals_sorted_by_keyr��s)���%�*�*�,�,���D��u�y�$���r#c#�K�t|��}|D];}d}	|jd}t|��D]}|V��n#t$rYnwxYw|s|V��<dS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r��items�
deepvalues�AttributeError)�mapping�values�obj�subobjs    r!r�r��s�����
��
(�
(�F�������	��I�I��G�$�S�/�/�
�
�������
��	�	�	�	��D�	�����	��I�I�I���s�9�
A�Ac��eZdZdS)�AbsentN�r9r:r;r=r#r!r�r����������r#r�c��eZdZdZejd��Zejd��Zejd��Zejd��Z	ejd��Z
ejdej��Zdd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Ze ��d���Z!d�Z"dS) rz�Collection of HTTP cookies.

    You may not need to know about this class: try
    urllib.request.build_opener(HTTPCookieProcessor).open(url).
    z\Wr�z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)Nc�r�|�t��}||_tj��|_i|_dSr")r�_policy�
_threading�RLock�
_cookies_lock�_cookies�r�policys  r!r zCookieJar.__init__�s5���>�(�*�*�F����'�-�/�/�����
�
�
r#c��||_dSr")r�r�s  r!�
set_policyzCookieJar.set_policy�s
������r#c��g}|j�||��sgStd|��|j|}|���D]�}|j�||��s�||}|���D]Q}|j�||��std���-td��|�|���R��|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r�rIr"r�r�rLr�rFr�)rr�r��cookies�cookies_by_pathr��cookies_by_namerCs        r!�_cookies_for_domainzCookieJar._cookies_for_domain�s������|�,�,�V�W�=�=�	��I��2�F�;�;�;��-��/��#�(�(�*�*�		'�		'�D��<�.�.�t�W�=�=�
��-�d�3�O�)�0�0�2�2�
'�
'���|�-�-�f�g�>�>���4�5�5�5���(�)�)�)����v�&�&�&�&�
'��r#c��g}|j���D]+}|�|�||�����,|S)z2Return a list of cookies to be returned to server.)r�r��extendr�)rr�r�r�s    r!�_cookies_for_requestzCookieJar._cookies_for_request�sP�����m�(�(�*�*�	F�	F�F��N�N�4�3�3�F�G�D�D�E�E�E�E��r#c�>�|�d�d���d}g}|D�]|}|j}|s d}|dkr|�d|z��|j�F|j�|j��r'|dkr!|j�d|j��}n|j}|j�|�|j��n|�|j�d	|����|dkr�|j	r|�d
|j
z��|j�d��rE|j}|j
s|�d��r
|dd�}|�d
|z��|j�+d}|jr
|d|jzz}|�|����~|S)z�Return a list of cookie-attributes to be returned to server.

        like ['foo="bar"; $Path="/"', ...]

        The $Version attribute is also added when appropriate (currently only
        once per request).

        c�*�t|j��Sr")r�r�)�as r!�<lambda>z)CookieJar._cookie_attrs.<locals>.<lambda>s��3�q�v�;�;�r#T)�key�reverseFrz$Version=%sNr�r�z
$Path="%s"r�r3z$Domain="%s"z$Portz="%s")�sortr�r�r��non_word_rero�quote_rer�r�rr�r�r�rr�r)	rr�r��attrsrCr�r�r�r1s	         r!�
_cookie_attrszCookieJar._cookie_attrss���	���.�.���=�=�=������(	$�(	$�F��n�G��
:�"���Q�;�;��L�L���!8�9�9�9�
��)�� �'�'���5�5�*�:A�A�+�+��
�)�)�'�6�<�@�@�������|�#����V�[�)�)�)�)��������U�U�;�<�<�<���{�{��(�=��L�L����!;�<�<�<��=�+�+�C�0�0�:�#�]�F�"�5�,��)�)�#�.�.�,�!'�������L�L��&�!8�9�9�9��;�*��A��,�8���6�;�!6�7���L�L��O�O�O���r#c���td��|j���	tt	j����x|j_|_|�|��}|�|��}|r>|�	d��s)|�
dd�|����|jjrI|jj
s=|�	d��s(|D]%}|jdkr|�
dd��n�&|j���n#|j���wxYw|���dS)z�Add correct Cookie: header to request (urllib.request.Request object).

        The Cookie2 header is also added unless policy.hide_cookie2 is true.

        �add_cookie_headerrr��Cookie2r3z$Version="1"N)r"r��acquirerr|r�r�r�r��
has_header�add_unredirected_headerr�rPrRr��release�clear_expired_cookies)rr�r�r�rCs     r!r�zCookieJar.add_cookie_header<ss��	�"�#�#�#���"�"�$�$�$�	)�,/��	���,<�,<�<�D�L���	��/�/��8�8�G��&�&�w�/�/�E��
4��)�)�(�3�3�4��3�3� �$�)�)�E�"2�"2�4�4�4���$�
�T�\�-F�
��&�&�y�1�1�
�%���F��~��*�*��7�7�	�>�R�R�R���+�

��&�&�(�(�(�(��D��&�&�(�(�(�(�����"�"�$�$�$�$�$s�C0D4�4Ec�v�g}d}d}|D�].}|d\}}d}d}	i}
i}|dd�D]�\}}
|���}||vs||vr|}||vr|
�d}
||
vr�0|dkr)|
�td	��d}	n�|
���}
|d
kr|r�h|
�td���z|dkrAd}	t|
��}
n"#t$rtd
��d}	Yn@wxYwd
}|j|
z}
||vs||vr"|
�|dvrtd|z��d}	n|
|
|<��|
||<��|	r��|�|||
|f����0|S)aReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        )rr�)r�r�r�r�r�r�r�
commenturlrFr3NTr�z%   missing value for domain attributer�zM   missing or invalid value for expires attribute: treating as session cookier�z?   missing or invalid (non-numeric) value for max-age attribute)r�rr�z!   missing value for %s attribute)rzr"rr{r�r�)r�	attrs_set�
cookie_tuples�
boolean_attrs�value_attrs�cookie_attrsr�r��max_age_set�
bad_cookie�standardrr�r�r�s               r!�_normalized_cookie_tuplesz#CookieJar._normalized_cookie_tuples]s���
�+�
�0��
&�H	@�H	@�L�&�q�/�K�D�%� �K��J��H��D�$�Q�R�R�(�2
 �2
 ���1��W�W�Y�Y����$�$��m�(;�(;��A��
�%�%�!�)��A���=�=����=�=��y��F�G�G�G�%)�
������	�	�A��	�>�>�"�!� ��y�� F�G�G�G� ��	�>�>�"&�K����F�F����%����� 2�3�3�3�%)�
����	����"�A��	�A�
�A���$�$�!�}�*<�*<��	��!B�B�B��B�Q�F�G�G�G�%)�
���"#�H�Q�K�K��D��G�G��
��� � �$��x��!>�?�?�?�?��s�,B<�<C�Cc�2�|\}}}}|�dt��}|�dt��}|�dt��}	|�dt��}
|�dd��}|�"	t|��}n#t$rYdSwxYw|�dd��}|�dd��}
|�d	d��}|�d
d��}|tur|dkrd}t	|��}n_d}t|��}|�d
��}|dkr|dkr|d|�}n
|d|dz�}t|��dkrd
}|tu}d}|r"t|�	d����}|turt|��\}}|}n|�	d��sd|z}d}|	tur+|	�t|��}	nd}tj
dd|	��}	nd}	|
turd}
d}
nH|
|jkr=	|�|||��n#t $rYnwxYwt#d|||��dSt%||||	||||||||
|
|||��S)Nr�r�r�r�r�r�Frrr�r�Tr�r�rr3r�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r&r�rr{r�rr�r��boolr�r�rr�r�r��clear�KeyErrorr"r)r�tupr�r�r�rrr�r�r�r�r�r�rrrrr�rrr�r�rs                       r!�_cookie_from_cookie_tuplez#CookieJar._cookie_from_cookie_tuple�s
��'*�#��e�X�t����h��/�/���|�|�F�F�+�+���|�|�F�F�+�+���,�,�y�&�1�1���,�,�y�$�/�/����
��g�,�,�����
�
�
��t�t�
�������h��.�.���,�,�y�%�0�0���,�,�y�$�/�/���l�l�<��6�6���v���$�"�*�*�!�N��t�$�$�D�D�"�N���(�(�D��
�
�3���A��B�w�w��a�<�<�����8�D�D����1���:�D��4�y�y�A�~�~�c�t�"��/��"���	>�!%�f�&7�&7��&<�&<�!=�!=���V���-�g�6�6�N�H�d��F�F��"�"�3�'�'�	 ���Z�F����v����|�$�G�,�,���!%���v�f�b�$�/�/����D��f����G��G�G�
��	�
!�
!�
��
�
�6�4��.�.�.�.���
�
�
���
�����G��4��
'�
'�
'��4��g��E��N��.�0B��N�����!��
�
�
	s$�
B�
B+�*B+�?I�
I$�#I$c��|�|��}g}|D]/}|�||��}|r|�|���0|Sr")rrr�)rr�r�r�r�rrCs       r!�_cookies_from_attrs_setz!CookieJar._cookies_from_attrs_sets[���6�6�y�A�A�
��� �	.�	.�C��3�3�C��A�A�F��-�w�~�~�f�-�-�-���r#c��t|jdd��}|�
|jj}|D]}|jdkrd|_|rd|_�dS)NrQr3Tr)r6r�rPr�r)rr��
rfc2109_as_nsrCs    r!�_process_rfc2109_cookiesz"CookieJar._process_rfc2109_cookies#sh�����.C�T�J�J�
�� � $�� 4�4�M��	'�	'�F��~��"�"�!%��� �'�&'�F�N��
	'�	'r#c��|���}|�dg��}|�dg��}|jj}|jj}|s|r|s|r|s|r|s|sgS	|�t
|��|��}n #t$rt��g}YnwxYw|r�|r�	|�t|��|��}	n #t$rt��g}	YnwxYw|�
|	��|r3i}
|D]}d|
|j|j|j
f<�|
fd�}t||	��}	|	r|�|	��|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNc�2�|j|j|jf}||vSr")r�r�r�)�	ns_cookie�lookupr�s   r!�no_matching_rfc2965z3CookieJar.make_cookies.<locals>.no_matching_rfc2965[s ��#�*�I�N�I�N�J�C��f�,�,r#)r��get_allr�rPrOr	r��	Exceptionr0r�rr�r�r�rr�)
r�responser�r��rfc2965_hdrs�ns_hdrsrPrOr��
ns_cookiesrrCrs
             r!�make_cookieszCookieJar.make_cookies/s����-�-�/�/�����}�b�9�9���/�/�,��3�3���,�&���<�(���	�g�	��	�!(�	��	�&.�	��	�#*�	��I�	��2�2�"�<�0�0�'�;�;�G�G���	�	�	�%�'�'�'��G�G�G�	�����	+�x�	+�
 �!�9�9�$�W�-�-�w�8�8�
�
���
 �
 �
 �)�+�+�+��
�
�
�
 ����
�)�)�*�5�5�5��
E���%�M�M�F�HL�F�F�M�6�;���D�E�E�:@�-�-�-�-�$�$7��D�D�
��
+����z�*�*�*��s$�,#B�B-�,B-�5#C�C6�5C6c�j�|j���	ttj����x|j_|_|j�||��r|�|��|j���dS#|j���wxYw)z-Set a cookie if policy says it's OK to do so.N)	r�r�rr|r�r�rD�
set_cookier�rBs   r!�set_cookie_if_okzCookieJar.set_cookie_if_okes�����"�"�$�$�$�	)�,/��	���,<�,<�<�D�L���	��|�"�"�6�7�3�3�
(�����'�'�'�
��&�&�(�(�(�(�(��D��&�&�(�(�(�(���s�A!B�B2c�J�|j}|j���	|j|vr
i||j<||j}|j|vr
i||j<||j}|||j<|j���dS#|j���wxYw)z?Set a cookie, without checking whether or not it should be set.N)r�r�r�r�r�r�r�)rrC�c�c2�c3s     r!rzCookieJar.set_cookiers����M����"�"�$�$�$�	)��}�A�%�%�"�q���'7��6�=�!�B��{�"�$�$��b���o��F�K��B�$�B�v�{�O���&�&�(�(�(�(�(��D��&�&�(�(�(�(���s�A
B�B"c��td|�����|j���	t	tj����x|j_|_|�||��D]B}|j�	||��r%td|��|�
|���C	|j���dS#|j���wxYw)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)r"r�r�r�rr|r�r�rrDrr�)rrr�rCs    r!�extract_cookieszCookieJar.extract_cookiess����$�h�m�m�o�o�6�6�6���"�"�$�$�$�	)�,/��	���,<�,<�<�D�L���	��+�+�H�g�>�>�
,�
,���<�&�&�v�w�7�7�,��0�&�9�9�9��O�O�F�+�+�+��
,�

��&�&�(�(�(�(�(��D��&�&�(�(�(�(���s�B
C#�#C>c���|�)|�|�td���|j|||=dS|�!|�td���|j||=dS|�
|j|=dSi|_dS)a�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)r{r�)rr�r�r�s    r!rzCookieJar.clear�s�������D�L� �N�P�P�P��
�f�%�d�+�D�1�1�1�
�
��~� �D�F�F�F��
�f�%�d�+�+�+�
�
��
�f�%�%�%��D�M�M�Mr#c��|j���	|D]/}|jr&|�|j|j|j���0	|j���dS#|j���wxYw)z�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N)r�r�rrr�r�r�r�)rrCs  r!�clear_session_cookieszCookieJar.clear_session_cookies�s���	
��"�"�$�$�$�	)��
H�
H���>�H��J�J�v�}�f�k�6�;�G�G�G��
H�
��&�&�(�(�(�(�(��D��&�&�(�(�(�(���s�2A)�)Bc�P�|j���	tj��}|D]=}|�|��r&|�|j|j|j���>	|j���dS#|j���wxYw)a�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N)	r�r�r|r.rr�r�r�r�)rr-rCs   r!r�zCookieJar.clear_expired_cookies�s���	
��"�"�$�$�$�	)��)�+�+�C��
H�
H���$�$�S�)�)�H��J�J�v�}�f�k�6�;�G�G�G��
H�
��&�&�(�(�(�(�(��D��&�&�(�(�(�(���s�AB
�
B%c�*�t|j��Sr")r�r�r_s r!�__iter__zCookieJar.__iter__�s���$�-�(�(�(r#c��d}|D]}|dz}�|S)z#Return number of contained cookies.rr3r=)rr�rCs   r!�__len__zCookieJar.__len__�s!��
���%�%�F��A��A�A��r#c��g}|D]$}|�t|�����%d|j�dd�|���d�S�N�<�[r�z]>)r�r7�	__class__r��r�rrCs   r!r8zCookieJar.__repr__�sN�����2�2�F�A�H�H�T�&�\�\�2�2�2�2�2�!�^�^�^�T�Y�Y�q�\�\�\�\�:�:r#c��g}|D]$}|�t|�����%d|j�dd�|���d�Sr+)r�rr.r�r/s   r!r4zCookieJar.__str__�sN�����1�1�F�A�H�H�S��[�[�1�1�1�1�1�!�^�^�^�T�Y�Y�q�\�\�\�\�:�:r#r")NNN)#r9r:r;r<r��compiler�r��strict_domain_re�	domain_re�dots_re�ASCII�magic_rer r�r�r�r�r�rrr	rrrrr!rr$r�r'r)rr8r4r=r#r!rr�s����������"�*�U�#�#�K��r�z�+�&�&�H�!�r�z�+�.�.����
�8�$�$�I��b�j��!�!�G��r�z�6���A�A�H�����������$���9�9�9�v%�%�%�B_�_�_�BZ�Z�Z�x���
'�
'�
'�4�4�4�l)�)�)�)�)�)�)�)�)�����6
)�
)�
)�)�)�)�&)�)�)�����]�_�_�;�;��_�;�
;�;�;�;�;r#rc��eZdZdS)rNr�r=r#r!rr�r�r#rc�6�eZdZdZdd�Zd	d�Zd	d�Z		d	d�ZdS)
rz6CookieJar that can be loaded from and saved to a file.NFc��t�||��|�	|dzn#td���xYw||_t	|��|_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        Nr�zfilename must be string-like)rr r{�filenamer�	delayload)rr;r<r�s    r!r zFileCookieJar.__init__�sb��	���4��(�(�(���
A�������
A� �!?�@�@�@���� ��
��i������s�%�6c��t���)zSave cookies to a file.r@)rr;�ignore_discard�ignore_expiress    r!�savezFileCookieJar.save�rGr#c��|�#|j�|j}ntt���t|��}	|�||||��|���dS#|���wxYw)zLoad cookies from a file.N)r;r{�MISSING_FILENAME_TEXTr
�_really_load�close�rr;r>r?r.s     r!�loadzFileCookieJar.load�st�����}�(�T�]�(�(�"�#8�9�9�9���N�N��	����a��>�>�J�J�J�
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s�A$�$A:c��|�#|j�|j}ntt���|j���	tj|j��}i|_	|�|||��n#ttf$r	||_�wxYw	|j���dS#|j���wxYw)z�Clear all cookies and reload cookies from a saved file.

        Raises LoadError (or IOError) if reversion is not successful; the
        object's state will not be altered if this happens.

        N)r;r{rBr�r�r�deepcopyr�rFr�IOErrorr�)rr;r>r?�	old_states     r!�revertzFileCookieJar.reverts������}�(�T�]�(�(�"�#8�9�9�9���"�"�$�$�$�	)��
�d�m�4�4�I��D�M�
��	�	�(�N�N�C�C�C�C���w�'�
�
�
� )��
��
����D�
��&�&�(�(�(�(�(��D��&�&�(�(�(�(���s$� B2�!A9�8B2�9B�B2�2C
)NFN�NFF)r9r:r;r<r r@rFrKr=r#r!rr�sr������@�@�
)�
)�
)�
)�$�$�$�$�
�
�
�
�#�49�)�)�)�)�)�)r#rc���|j|jfd|jfd|jfg}|j�|�d|jf��|jr|�d��|jr|�d��|jr|�d��|j	r|�d��|j
r6|�d	tt|j
����f��|j
r|�d
��|jr|�d|jf��|jr|�d|jf��t!|j�����}|D]1}|�|t'|j|��f���2|�d
t'|j��f��t+|g��S)z�Return string representation of Cookie in an the LWP cookie file format.

    Actually, the format is extended a bit -- see module docstring.

    r�r�Nr�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)rNrr�r�)r�r�r�r�r�r�rrrr�r�r_r�rrrr�rr�rr�r�)rCrr�r�s    r!�lwp_cookie_strrQs����+�v�|�	$�
�&�+�	�
�F�M�	"�	$�A��{�����&�&�+�)>� ?� ?� ?�
��;�a�h�h�':�;�;�;�
��;�a�h�h�':�;�;�;�
� �@�!�(�(�+?�"@�"@�"@�
�}�0�a�h�h�/�0�0�0�
�~�B�q�x�x��(��v�~�)>�)>�?�?�!A�B�B�B�
�~�2�q�x�x� 1�2�2�2�
�~�<�q�x�x��F�N� ;�<�<�<�
��G�1�8�8�\�6�3E�$F�G�G�G��&�,�#�#�%�%�&�&�D�
�,�,��	���!�S���a��)�)�*�+�+�+�+��H�H�i��V�^�,�,�
-�.�.�.��a�S�!�!�!r#c�(�eZdZdZdd�Zd	d�Zd�ZdS)
raZ
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl libary, not known
    to be compatible with any browser, but which is easy to read and
    doesn't lose information about RFC 2965 cookies.

    Additional methods

    as_lwp_str(ignore_discard=True, ignore_expired=True)

    Tc��tj��}g}|D]I}|s|jr�|s|�|��r�$|�dt	|��z���Jd�|dgz��S)z�Return cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s�
r�)r|rr.r�rQr�)rr>r?r-r0rCs      r!�
as_lwp_strzLWPCookieJar.as_lwp_strHs����i�k�k�����	A�	A�F�!�
�f�n�
��!�
�f�&7�&7��&<�&<�
��
�H�H�&���)?�)?�?�@�@�@�@��y�y��B�4�� � � r#NFc�H�|�#|j�|j}ntt���t|d��}	|�d��|�|�||����|���dS#|���wxYw)N�wz#LWP-Cookies-2.0
)r;r{rBr
�writerUrDrEs     r!r@zLWPCookieJar.saveXs������}�(�T�]�(�(�"�#8�9�9�9���3����	�
�G�G�(�)�)�)�
�G�G�D�O�O�N�N�C�C�D�D�D�
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s�>B�B!c���|���}|j�|��sd|z}t|���t	j��}d}d}	d}
		|���}|dkrdS|�|��s�3|t
|��d����}t|g��D�]f}|d\}
}i}i}|	D]}d||<�|dd�D]E\}}|�|�	��}nd}||
vs||	vr|}||	vr
|�d	}|||<�6||
vr|||<�@|||<�F|j
}|d
��}|d��}|�t|��}|�d	}|d��}|�d
��}t|d��|
||d��|d��|||d��|d��|d��|d��|||d��|d��|��}|s	|j
r��8|s|�|��r��Q|�|����h���#t $r�t"$r$t%��td|�d|�����wxYw)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)rOrNrPr�r)r�r�r�r�r�rr�r3r�rFTr�rr�r�r�r�rOrPr�rNr�rr�z invalid Set-Cookie3 format file �: )�readliner7rorr|r�r��stripr�rzr&r�rrr.rrIrr0)rr.r;r>r?�magicr/r-�headerr�r��line�datar�r�rrr�r�r�rr�rr�rrs                          r!rCzLWPCookieJar._really_loadgs%���
�
�����}�#�#�E�*�*�	!��$�%�C��C�.�.� ��i�k�k����.�
�0��
<	.�4
'��z�z�|�|���2�:�:�u�u����v�.�.����C��K�K�L�L�)�/�/�1�1��.��v�6�6�-'�-'�D�"&�q�'�K�D�%�!�H��D�*�,�,��&+����� $�Q�R�R��(�(���1��=�!"�����B�B�!%�B��+�-�-�2��3F�3F� "�A��
�-�-� �y�d�!�*+�H�Q�K�K��+�-�-�*+�H�Q�K�K�&'�D��G�G� ��A��a�	�l�l�G��a�	�l�l�G��*�"*�7�"3�"3����"&���Q�x�[�[�F�'-�'8�'8��'=�'=�$��q�q��|�|�T�5� �q��y�y�!�!�K�.�.�%�'7���<��� �q��y�y�!�!�K�.�.� �q��{�{�&�&� �q��|�|� �q����#�	%�	%�A�*�!�a�i�!� �)�!�a�l�l�3�.?�.?�!� ��O�O�A�&�&�&�&�i4
'��l�	�	�	���	.�	.�	.�%�'�'�'��)�%�X�X�t�t�-�.�.�
.�	.���s�H3�:F9H3�38I+)TTrL)r9r:r;r<rUr@rCr=r#r!rr;sZ������
�
�!�!�!�!� 
�
�
�
�M.�M.�M.�M.�M.r#rc�D�eZdZdZejd��ZdZd�Zdd�Z	dS)	ra�

    WARNING: you may want to backup your browser's cookies file if you use
    this class to save cookies.  I *think* it works, but there have been
    bugs in the past!

    This class differs from CookieJar only in the format it uses to save and
    load cookies to and from a file.  This class uses the Mozilla/Netscape
    `cookies.txt' format.  lynx uses this file format, too.

    Don't expect cookies saved while the browser is running to be noticed by
    the browser (in fact, Mozilla on unix will overwrite your saved cookies if
    you change them on disk while it's running; on Windows, you probably can't
    save at all while the browser is running).

    Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
    Netscape cookies on saving.

    In particular, the cookie version and port number information is lost,
    together with information about whether or not Path, Port and Discard were
    specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
    domain as set in the HTTP header started with a dot (yes, I'm aware some
    domains in Netscape files start with a dot and some don't -- trust me, you
    really don't want to know any more about this).

    Note that though Mozilla and Netscape use the same format, they use
    slightly different headers.  The class saves cookies using the Netscape
    header by default (Mozilla can cope with that).

    z#( Netscape)? HTTP Cookie Filez~# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file!  Do not edit.

c��tj��}|���}|j�|��s&|���td|z���		|���}|dkrdS|�d��r
|dd�}|����d��s|���dkr�||�	d��\}}	}
}}}
}|dk}|	dk}	|
dkr|}
d}|�d	��}|	|ksJ�d
}|dkrd}d}td|
|dd
||	||
d
|||ddi��}|s	|jr��|s|�|��r��|�
|����0#t$r�t$r$t!��td
|�d|�����wxYw)Nz4%r does not look like a Netscape format cookies filer3r�rTr�)�#r�	�TRUEr�FTrz%invalid Netscape format cookies file rZ)r|r[r7rorDrr�r\r�r�rrr.rrIrr0)rr.r;r>r?r-r]r_r�rr�r�r�r�r�r�rrs                  r!rCzMozillaCookieJar._really_load�sL���i�k�k���
�
�����}�#�#�E�*�*�	�
�G�G�I�I�I��F�����
�6	.�.
#��z�z�|�|���2�:�:�u�u��=�=��&�&�8�t�C�R�C�y���J�J�L�L�+�+�J�7�7���J�J�L�L�B�&�&���
�
�4�(�(�M��(�$����u� �F�*��$4��$>� ��2�:�:�!�D� �E�$�/�/��4�4��'�;�6�6�6�6����b�=�=�"�G�"�G��1�d�E���!�#3�[���!�"�"����	�	��&��!�)���%��!�,�,�s�*;�*;�������"�"�"�].
#��`�	�	�	���	.�	.�	.�%�'�'�'��)�%�X�X�t�t�-�.�.�
.�	.���s�)F�DF�8GNFc��|�#|j�|j}ntt���t|d��}	|�|j��t
j��}|D]�}|s|jr�|s|�|��r�$|j	rd}nd}|j
�d��rd}nd}|j�t|j��}	nd}	|j�
d}
|j}n|j}
|j}|�d�|j
||j||	|
|g��dz����	|���dS#|���wxYw)NrWre�FALSEr�r�rdrT)r;r{rBr
rXr^r|rr.r�r�r�r�rr�r�r�r�rD)rr;r>r?r.r-rCr�r�r�r�r�s            r!r@zMozillaCookieJar.save s������}�(�T�]�(�(�"�#8�9�9�9���3����	�
�G�G�D�K� � � ��)�+�+�C��
�
��%��&�.���%��&�*;�*;�C�*@�*@����=�'�6�&�&�&�f��=�+�+�C�0�0�,��+�+�$+�k��>�-�!�&�.�1�1�G�G� �G��<�'��D�"�K�E�E�!�;�D�"�L�E�����I�I�v�}�k�6�;�%�w��e�=�>�>�������-
�6
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s�C8E�ErL)
r9r:r;r<r�r2r7r^rCr@r=r#r!rr�s`��������<�r�z�:�;�;�H��F�@.�@.�@.�D$�$�$�$�$�$r#rr")fr<�
__future__rrrr�future.builtinsrrr	r
r�future.utilsrr
�__all__rrVr�r6r|�future.backports.urllib.parserrr�future.backports.http.clientr�	threadingr��ImportError�dummy_threading�calendarrrrr"rrBr0r9rArarcrxr<r�rzr_rdrmr2rnrtr�r��Ir��Xr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rr�rr�objectrrrr�r�r�rrIrrrQrrr=r#r!�<module>rus�����<(�'�'�'�'�'�%�%�%�%�%�%�������&�&�&�&�&�&�7�7�7�7�7�7�7�7�7�7�7�7�7�7�+�+�+�+�+�+�+�+�M�M�M����������	�	�	�	����B�H�����C�C�C�C�C�C�C�C�C�C�2�2�2�2�2�2�)�"�"�"�"�"���)�)�)�(�(�(�(�(�(�)����������
��	
������C�	�N�N��:��A�A�A��
����9�8�8��
4�
4�
4����
�7�7�E�\�(�(������7�7�7�7�B�B�B�B�&0�0�0�0�(��T��=�=�	��b�j�5�r�x�@�@�����3
�3
�3
�j���+�,.�H�6�6���R�Z�2�B�D�2�8�O�E�E�
��R�Z��&
�D�2�8�O�)���*65�65�65�p�b�j�
� �4�"�)��#���$5�5�5�B3�3�3�
$���$6�7�7��#���$M�N�N��#���$9�:�:���2�:�h�'�'��S�S�S�j#��
�;�/�/�����2���1�1�1�h�"�*�Y���
)�
)��
�
�
�%�%�%�N������(�b�j��2�8�,�,����� 	�	�	������� $���"�*�9�:�:��+�+�+����!
�!
�!
�F���"e.�e.�e.�e.�e.�V�e.�e.�e.�P�����6����BN�N�N�N�N�,�N�N�N�b
 � � ����&�����V����N;�N;�N;�N;�N;��N;�N;�N;�d���������:)�:)�:)�:)�:)�I�:)�:)�:)�z"�"�"�8y.�y.�y.�y.�y.�=�y.�y.�y.�xM�M�M�M�M�}�M�M�M�M�Ms�A$�$	A0�/A0

Hacked By AnonymousFox1.0, Coded By AnonymousFox