
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    ¡ê,a¼O  ã                   @   st  d Z ddlZddlZdddgZdjZdjZdjZG d	d„ deƒZ	ej
ej d
 Zed Zdd„ eedƒƒeeeeƒƒ D ƒZe edƒdedƒdi¡ e de e¡ ¡jZdd„ Ze d¡Ze d¡Zdd„ Zddddddd gZdd!d"d#d$d%d&d'd(d)d*d+d,gZdeefd-d.„ZG d/d0„ d0eƒZ d1Z!e!d2 Z"e d3e! d4 e" d5 ej#ej$B ¡Z%G d6d„ deƒZ&G d7d„ de&ƒZ'dS )8a.
  
Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
é    NÚCookieErrorÚ
BaseCookieÚSimpleCookieÚ z; ú c                   @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r
   r
   ú1/opt/alt/python38/lib64/python3.8/http/cookies.pyr   �   s   z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}c                 C   s   i | ]}|d | “qS )z\%03or
   )Ú.0Únr
   r
   r   Ú
<dictcomp>¤   s   ÿ r   é   ú"ú\"ú\z\\z[%s]+c                 C   s*   | dkst | ƒr| S d|  t¡ d S dS )zãQuote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr   )Ú_is_legal_keyÚ	translateÚ_Translator©Ústrr
   r
   r   Ú_quote­   s    r   z\\[0-3][0-7][0-7]z[\\].c                 C   sN  | d kst | ƒdk r| S | d dks0| d dkr4| S | dd… } d}t | ƒ}g }d|  krf|k �rFn nÜt | |¡}t | |¡}|s |s | | |d … ¡ �qFd }}|r¶| d¡}|rÄ| d¡}|�r|rØ||k �r| | ||… ¡ | | |d  ¡ |d }qP| | ||… ¡ | tt| |d |d … dƒƒ¡ |d }qPt|ƒS )Né   r   r   éÿÿÿÿé   é   é   )	ÚlenÚ
_OctalPattÚsearchÚ
_QuotePattÚappendÚstartÚchrÚintÚ	_nulljoin)r   Úir   ÚresZo_matchZq_matchÚjÚkr
   r
   r   Ú_unquote½   s6    


$
r+   ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc              	   C   sR   ddl m}m } |ƒ }|||  ƒ\	}}}}	}
}}}}d|| ||| ||	|
|f S )Nr   )ÚgmtimeÚtimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r-   r,   )ZfutureZweekdaynameZ	monthnamer,   r-   ZnowZyearZmonthZdayZhhZmmZssZwdÚyÚzr
   r
   r   Ú_getdateõ   s    ÿr0   c                
   @   sÖ   e Zd ZdZdddddddd	d
dœ	ZddhZdd„ Zedd„ ƒZedd„ ƒZ	edd„ ƒZ
dd„ Zd2dd„Zdd„ ZejZdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd3d*d+„ZeZd,d-„ Zd4d.d/„Zd5d0d1„ZdS )6ÚMorselaC  A class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.
    ÚexpiresÚPathÚCommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r2   ÚpathÚcommentZdomainúmax-ageÚsecureÚhttponlyÚversionZsamesiter8   r9   c                 C   s0   d  | _  | _| _| jD ]}t | |d¡ qd S )Nr   )Ú_keyÚ_valueÚ_coded_valueÚ	_reservedÚdictÚ__setitem__)ÚselfÚkeyr
   r
   r   Ú__init__   s    
zMorsel.__init__c                 C   s   | j S ©N)r;   ©rA   r
   r
   r   rB   (  s    z
Morsel.keyc                 C   s   | j S rD   )r<   rE   r
   r
   r   Úvalue,  s    zMorsel.valuec                 C   s   | j S rD   )r=   rE   r
   r
   r   Úcoded_value0  s    zMorsel.coded_valuec                 C   s2   |  ¡ }|| jkr td|f ƒ‚t | ||¡ d S ©NzInvalid attribute %r)Úlowerr>   r   r?   r@   )rA   ÚKÚVr
   r
   r   r@   4  s    
zMorsel.__setitem__Nc                 C   s.   |  ¡ }|| jkr td|f ƒ‚t | ||¡S rH   )rI   r>   r   r?   Ú
setdefault)rA   rB   Úvalr
   r
   r   rL   :  s    
zMorsel.setdefaultc                 C   s>   t |tƒstS t | |¡o<| j|jko<| j|jko<| j|jkS rD   )Ú
isinstancer1   ÚNotImplementedr?   Ú__eq__r<   r;   r=   ©rA   Zmorselr
   r
   r   rP   @  s    

ÿ
þ
ýzMorsel.__eq__c                 C   s$   t ƒ }t || ¡ |j | j¡ |S rD   )r1   r?   ÚupdateÚ__dict__rQ   r
   r
   r   ÚcopyJ  s    zMorsel.copyc                 C   sR   i }t |ƒ ¡ D ]0\}}| ¡ }|| jkr8td|f ƒ‚|||< qt  | |¡ d S rH   )r?   ÚitemsrI   r>   r   rR   )rA   ÚvaluesÚdatarB   rM   r
   r
   r   rR   P  s    

zMorsel.updatec                 C   s   |  ¡ | jkS rD   )rI   r>   )rA   rJ   r
   r
   r   ÚisReservedKeyY  s    zMorsel.isReservedKeyc                 C   sH   |  ¡ | jkrtd|f ƒ‚t|ƒs2td|f ƒ‚|| _|| _|| _d S )Nz Attempt to set a reserved key %rzIllegal key %r)rI   r>   r   r   r;   r<   r=   )rA   rB   rM   Z	coded_valr
   r
   r   Úset\  s    z
Morsel.setc                 C   s   | j | j| jdœS )N)rB   rF   rG   ©r;   r<   r=   rE   r
   r
   r   Ú__getstate__g  s    ýzMorsel.__getstate__c                 C   s"   |d | _ |d | _|d | _d S )NrB   rF   rG   rZ   )rA   Ústater
   r
   r   Ú__setstate__n  s    

zMorsel.__setstate__úSet-Cookie:c                 C   s   d||   |¡f S )Nz%s %s)ÚOutputString)rA   ÚattrsÚheaderr
   r
   r   Úoutputs  s    zMorsel.outputc                 C   s   d| j j|  ¡ f S )Nú<%s: %s>)Ú	__class__r   r_   rE   r
   r
   r   Ú__repr__x  s    zMorsel.__repr__c                 C   s   d|   |¡ dd¡ S )Nz—
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        r   r   )r_   Úreplace)rA   r`   r
   r
   r   Ú	js_output{  s    úzMorsel.js_outputc                 C   s$  g }|j }|d| j| jf ƒ |d kr,| j}t|  ¡ ƒ}|D ]Þ\}}|dkrNq<||krXq<|dkr†t|tƒr†|d| j| t|ƒf ƒ q<|dkr°t|tƒr°|d| j| |f ƒ q<|dkrÞt|t	ƒrÞ|d| j| t
|ƒf ƒ q<|| jk�r|�r|t	| j| ƒƒ q<|d| j| |f ƒ q<t|ƒS )Nú%s=%sr   r2   r7   z%s=%dr6   )r"   rB   rG   r>   ÚsortedrU   rN   r%   r0   r   r   Ú_flagsÚ_semispacejoin)rA   r`   Úresultr"   rU   rB   rF   r
   r
   r   r_   …  s,    zMorsel.OutputString)N)Nr^   )N)N)r   r   r	   Ú__doc__r>   rj   rC   ÚpropertyrB   rF   rG   r@   rL   rP   ÚobjectÚ__ne__rT   rR   rX   rY   r[   r]   rb   Ú__str__re   rg   r_   r
   r
   r
   r   r1   ý   sD   ÷



	


r1   z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]zŒ
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	  ]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-  ]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c                   @   sn   e Zd ZdZdd„ Zdd„ Zddd„Zd	d
„ Zdd„ Zddd„Z	e	Z
dd„ Zddd„Zdd„ Zefdd„ZdS )r   z'A container class for a set of Morsels.c                 C   s   ||fS )a
  real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r
   ©rA   rM   r
   r
   r   Úvalue_decodeÌ  s    zBaseCookie.value_decodec                 C   s   t |ƒ}||fS )zýreal_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        r   ©rA   rM   Zstrvalr
   r
   r   Úvalue_encodeÕ  s    zBaseCookie.value_encodeNc                 C   s   |r|   |¡ d S rD   )Úload)rA   Úinputr
   r
   r   rC   Þ  s    zBaseCookie.__init__c                 C   s.   |   |tƒ ¡}| |||¡ t | ||¡ dS )z+Private method for setting a cookie's valueN)Úgetr1   rY   r?   r@   )rA   rB   Z
real_valuerG   ÚMr
   r
   r   Z__setâ  s    zBaseCookie.__setc                 C   s:   t |tƒrt | ||¡ n|  |¡\}}|  |||¡ dS )zDictionary style assignment.N)rN   r1   r?   r@   ru   Ú_BaseCookie__set)rA   rB   rF   ÚrvalÚcvalr
   r
   r   r@   è  s    
zBaseCookie.__setitem__r^   ú
c                 C   s:   g }t |  ¡ ƒ}|D ]\}}| | ||¡¡ q| |¡S )z"Return a string suitable for HTTP.)ri   rU   r"   rb   Újoin)rA   r`   ra   Úseprl   rU   rB   rF   r
   r
   r   rb   ñ  s
    zBaseCookie.outputc                 C   sJ   g }t |  ¡ ƒ}|D ] \}}| d|t|jƒf ¡ qd| jjt|ƒf S )Nrh   rc   )ri   rU   r"   ÚreprrF   rd   r   Ú
_spacejoin)rA   ÚlrU   rB   rF   r
   r
   r   re   û  s
    zBaseCookie.__repr__c                 C   s6   g }t |  ¡ ƒ}|D ]\}}| | |¡¡ qt|ƒS )z(Return a string suitable for JavaScript.)ri   rU   r"   rg   r&   )rA   r`   rl   rU   rB   rF   r
   r
   r   rg     s
    zBaseCookie.js_outputc                 C   s4   t |tƒr|  |¡ n| ¡ D ]\}}|| |< qdS )zÝLoad cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)rN   r   Ú_BaseCookie__parse_stringrU   )rA   ZrawdatarB   rF   r
   r
   r   rv   
  s
    

zBaseCookie.loadc                 C   s„  d}t |ƒ}g }d}d}d}d|  kr2|k �rn næ| ||¡}	|	sJ�q|	 d¡|	 d¡ }
}|	 d¡}|
d dkr–|s|q| ||
dd … |f¡ q|
 ¡ tjkrð|s¬d S |d krÚ|
 ¡ tjkrÔ| ||
df¡ qîd S n| ||
t	|ƒf¡ q|d k	�r| ||
|  
|¡f¡ d}qd S qd }|D ]Z\}}
}||k�rP|d k	�sFt‚|||
< n,||k�s^t‚|\}}|  |
||¡ | |
 }�q$d S )	Nr   Fr   r   rB   rM   ú$T)r   ÚmatchÚgroupÚendr"   rI   r1   r>   rj   r+   rs   ÚAssertionErrorrz   )rA   r   Zpattr'   r   Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZTYPE_KEYVALUEr…   rB   rF   ry   Útpr{   r|   r
   r
   r   Z__parse_string  sJ    



zBaseCookie.__parse_string)N)Nr^   r}   )N)r   r   r	   rm   rs   ru   rC   rz   r@   rb   rq   re   rg   rv   Ú_CookiePatternrƒ   r
   r
   r
   r   r   É  s   		
	

c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r   zþ
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    c                 C   s   t |ƒ|fS rD   )r+   rr   r
   r
   r   rs   \  s    zSimpleCookie.value_decodec                 C   s   t |ƒ}|t|ƒfS rD   )r   r   rt   r
   r
   r   ru   _  s    zSimpleCookie.value_encodeN)r   r   r	   rm   rs   ru   r
   r
   r
   r   r   U  s   )(rm   ÚreÚstringÚ__all__r~   r&   rk   r�   Ú	Exceptionr   Zascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrY   ÚrangeÚmapÚordr   rR   ÚcompileÚescapeÚ	fullmatchr   r   r   r!   r+   Z_weekdaynameZ
_monthnamer0   r?   r1   Z_LegalKeyCharsZ_LegalValueCharsÚASCIIÚVERBOSErŠ   r   r   r
   r
   r
   r   Ú<module>'   sr   ]
ÿ  þ

2          þ 4ýýôô
ï 