CasperSecurity

Current Path : /usr/lib/python3.10/http/__pycache__/
Upload File :
Current File : //usr/lib/python3.10/http/__pycache__/cookies.cpython-310.pyc

o

`�wiQ�@sldZddlZddlZddlZgd�ZdjZdjZdjZGdd�de	�Z
ejejd	Z
e
d
Zdd�eed
��eeee��D�Ze�ed�ded�di�e�de�e
��jZe�d�Zdd�Zdd�Ze�d�jZdd�Zdd�Zgd�Z gd�Z!de e!fdd �Z"Gd!d"�d"e#�Z$d#Z%e%d$Z&e�d%e%d&e&d'ej'ej(B�Z)Gd(d)�d)e#�Z*Gd*d+�d+e*�Z+dS),a%

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=;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;"

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eZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�#/usr/lib/python3.10/http/cookies.pyr�srz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|�qS)z\%03or
)�.0�nr
r
r�
<dictcomp>�s�r��"�\"�\z\\z[%s]+z[\x00-\x1F\x7F]cGstdd�|D��S)zhDetects control characters within a value.
    Supports any type, as header values can be any type.
    css�|]
}t�t|��VqdS�N)�_control_character_re�search�str)r�vr
r
r�	<genexpr>�s�z)_has_control_character.<locals>.<genexpr>)�any)�valr
r
r�_has_control_character�srcCs&|dust|�r
|Sd|�t�dS)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�rr
r
r�_quote�sr z\\(?:([0-3][0-7][0-7])|(.))cCs"|dr
tt|dd��S|dS)N���)�chr�int)�mr
r
r�_unquote_replace�sr'cCsJ|dus
t|�dkr|S|ddks|ddkr|S|dd�}tt|�S)Nr#rr���r!)�len�_unquote_subr'rr
r
r�_unquote�s
r+)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)
N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r@r?)�future�weekdayname�	monthnamer?r@�now�year�month�day�hh�mm�ss�wd�y�zr
r
r�_getdate�s�rNc
@s�eZdZdZdddddddd	d
d�	Zdd
hZdd�Zedd��Zedd��Z	edd��Z
dd�Zd2dd�Zdd�Z
ejZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d*d+�ZeZd,d-�Zd2d.d/�Zd2d0d1�Zeej�ZdS)4�MorselaCA 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�Comment�DomainzMax-Age�Secure�HttpOnly�Version�SameSite)	rP�path�comment�domain�max-age�secure�httponly�version�samesiter\r]cCs0d|_|_|_|jD]	}t�||d�qdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyr
r
r�__init__s
�zMorsel.__init__cC�|jSr)r`�rfr
r
rrg �z
Morsel.keycCrir)rarjr
r
r�value$rkzMorsel.valuecCrir)rbrjr
r
r�coded_value(rkzMorsel.coded_valuecCsP|��}||jvrtd|f��t||�rtd|�d|����t�|||�dS)N�Invalid attribute %rz.Control characters are not allowed in cookies r)�lowerrcrrrdre)rf�K�Vr
r
rre,s

zMorsel.__setitem__NcCsH|��}||jvrtd|f��t||�rtd||f��t�|||�S)Nrnz3Control characters are not allowed in cookies %r %r)rorcrrrd�
setdefault)rfrgrr
r
rrr4s

zMorsel.setdefaultcCs>t|t�stSt�||�o|j|jko|j|jko|j|jkSr)�
isinstancerO�NotImplementedrd�__eq__rar`rb�rf�morselr
r
rru<s

�
�
�z
Morsel.__eq__cCs$t�}t�||�|j�|j�|Sr)rOrd�update�__dict__rvr
r
r�copyFszMorsel.copycCsRi}t|���D]\}}|��}||jvrtd|f��|||<qt�||�dS)Nrn)rd�itemsrorcrrx)rf�values�datargrr
r
rrxLs

z
Morsel.updatecCs|��|jvSr)rorc)rfrpr
r
r�
isReservedKeyUszMorsel.isReservedKeycCsf|��|jvrtd|f��t|�std|f��t|||�r(td|||f��||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %rz6Control characters are not allowed in cookies %r %r %r)rorcrrrr`rarb)rfrgr�	coded_valr
r
r�setXs�
z
Morsel.setcCs|j|j|jd�S)N)rgrlrm�r`rarbrjr
r
r�__getstate__fs�zMorsel.__getstate__cCs"|d|_|d|_|d|_dS)Nrgrlrmr�)rf�stater
r
r�__setstate__ms

zMorsel.__setstate__�Set-Cookie:cCsd||�|�fS)Nz%s %s)�OutputString)rf�attrs�headerr
r
r�outputrsz
Morsel.outputcCsd|jj|��fS)N�<%s: %s>)�	__class__rr�rjr
r
r�__repr__wszMorsel.__repr__cCsd|�|��dd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)r��replace)rfr�r
r
r�	js_outputzs�zMorsel.js_outputcCs g}|j}|d|j|jf�|dur|j}t|���}|D]m\}}|dkr'q||vr,q|dkrCt|t�rC|d|j|t|�f�q|dkrXt|t�rX|d|j||f�q|dkrot|t	�ro|d|j|t
|�f�q||jvr�|r|t	|j|��q|d|j||f�qt|�S)N�%s=%srrPr[z%s=%drY)
�appendrgrmrc�sortedr{rsr%rNrr �_flags�_semispacejoin)rfr��resultr�r{rgrlr
r
rr��s.
�zMorsel.OutputStringr)Nr�)rrr	�__doc__rcr�rh�propertyrgrlrmrerrru�object�__ne__rzrxr~r�r�r�r��__str__r�r�r��classmethod�types�GenericAlias�__class_getitem__r
r
r
rrO�sH�



	



!rOz,\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@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�ZdS)rz'A container class for a set of Morsels.cCs||fS)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
�rfrr
r
r�value_decode�szBaseCookie.value_decodecCst|�}||fS)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�rfr�strvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r	|�|�dSdSr)�load)rf�inputr
r
rrh�s�zBaseCookie.__init__cCs.|�|t��}|�|||�t�|||�dS)z+Private method for setting a cookie's valueN)�getrOr�rdre)rfrg�
real_valuerm�Mr
r
r�__set�szBaseCookie.__setcCs<t|t�rt�|||�dS|�|�\}}|�|||�dS)zDictionary style assignment.N)rsrOrdrer��_BaseCookie__set)rfrgrl�rval�cvalr
r
rre�s
zBaseCookie.__setitem__r��
c	CsNg}t|���}|D]\}}|�||�}t|�rtd��|�|�q
|�|�S)z"Return a string suitable for HTTP.z-Control characters are not allowed in cookies)r�r{r�rrr��join)	rfr�r��sepr�r{rgrl�value_outputr
r
rr��s
zBaseCookie.outputcCsJg}t|���}|D]\}}|�d|t|j�f�q
d|jjt|�fS)Nr�r�)r�r{r��reprrlr�r�
_spacejoin)rf�lr{rgrlr
r
rr��s
zBaseCookie.__repr__cCs6g}t|���}|D]\}}|�|�|��q
t|�S)z(Return a string suitable for JavaScript.)r�r{r�r��	_nulljoin)rfr�r�r{rgrlr
r
rr�s
zBaseCookie.js_outputcCs6t|t�r|�|�dS|��D]\}}|||<qdS)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)rsr�_BaseCookie__parse_stringr{)rf�rawdatargrlr
r
rr�s

�
zBaseCookie.loadcCs�d}t|�}g}d}d}d}d|kr|kr�nnz|�||�}	|	s#nq|	�d�|	�d�}
}|	�d�}|
ddkrI|s<q|�||
dd�|f�n@|
��tjvru|sTdS|durj|
��tjvrh|�||
df�n!dS|�||
t	|�f�n|dur�|�||
|�
|�f�d}ndSd|kr�|ksnd}|D])\}
}
}|
|kr�|dus�J�|||
<q�|
|ks�J�|\}}|�|
||�||
}q�dS)	NrFr!r#rgr�$T)r)�match�group�endr�rorOrcr�r+r�r�)rfr�patt�ir
�parsed_items�morsel_seen�TYPE_ATTRIBUTE�
TYPE_KEYVALUEr�rgrlr��tpr�r�r
r
r�__parse_stringsN
�%

�zBaseCookie.__parse_stringr)Nr�r�)rrr	r�r�r�rhr�rer�r�r�r�r��_CookiePatternr�r
r
r
rr�s	
	
	
rc@s eZdZdZdd�Zdd�ZdS)rz�
    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.
    cCst|�|fSr)r+r�r
r
rr�`szSimpleCookie.value_decodecCst|�}|t|�fSr)rr r�r
r
rr�cszSimpleCookie.value_encodeN)rrr	r�r�r�r
r
r
rrYsr),r��re�stringr��__all__r�r�r�r��	Exceptionr�
ascii_letters�digits�_LegalChars�_UnescapedCharsr��range�map�ordrrx�compile�escape�	fullmatchrrrr �subr*r'r+�_weekdayname�
_monthnamerNrdrO�_LegalKeyChars�_LegalValueChars�ASCII�VERBOSEr�rrr
r
r
r�<module>s\&]��

=����
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY