? GR0V Shell

GR0V shell

Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64

Path : /lib64/python3.8/http/__pycache__/
File Upload :
Current File : //lib64/python3.8/http/__pycache__/cookiejar.cpython-38.opt-1.pyc

U

e5d#,@sdZddddddddgZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
l	Zd	d
l
Zd	d
lZ
d	dlmZdZd
ad
dZee
jjZdZddZdZddZdddddddgZddddd d!d"d#d$d%d&d'gZgZeD]Zee qdud(d)Z!dvd*d+Z"d
d
d
d
d,Z#e$d-ej%Z&d.d/Z'd0d1Z(e$d2ej%Z)e$d3ej*ej%BZ+e$d4ej,ej%BZ-d5d6Z.e$d7ej,ej%BZ/d8d9Z0d:d;Z1e$d<Z2e$d=Z3e$d>Z4e$d?Z5d@dAZ6e$dBZ7dCdDZ8dEdFZ9dGdHZ:e$dIej%Z;dJdKZ<dLdMZ=dNdOZ>dPdQZ?e$dRej%Z@dSdTZAdUdVZBdWdXZCdYdZZDd[ZEe$d\ZFd]d^ZGd_d`ZHdadbZIdcddZJGdeddZKGdfddZLGdgddeLZMdhdiZNdjdkZOGdldmdmZPGdnddZQGdoddeRZSGdpddeQZTdqdrZUGdsddeTZVGdtddeTZWd
S)waHTTP cookie handling for web clients.

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

Cookie	CookieJarCookiePolicyDefaultCookiePolicy
FileCookieJarLWPCookieJar	LoadErrorMozillaCookieJarN)timegmFcGs(tsdStsddl}|datj|S)Nr	zhttp.cookiejar)debugloggerloggingZ	getLogger)argsr
r&/usr/lib64/python3.8/http/cookiejar.py_debug,s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|}|d||}|jd|dddS)Nr	zhttp.cookiejar bug!
%s)
stacklevel)iowarnings	tracebackStringIO	print_excgetvaluewarn)rrrfmsgrrr_warn_unhandled_exception:s
ricCs|dd\}}}}}}|tkrd|kr4dkrnnhd|krLdkrnnPd|krddkrnn8d|kr|dkrnn d|krdkrnnt|SdSdS)	Nr	;=)
EPOCH_YEARr
)ttyearmonthZmdayhourminsecrrr_timegmIs&8


r,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtj}ntj|}d|j|j|j|j|j|jfS)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)	datetimeutcnowutcfromtimestampr'r(dayr)minutesecondtZdtrrr	time2isozWsr5cCsR|dkrtj}ntj|}dt||jt|jd|j|j	|j
|jfS)zReturn 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 GMTr)r-r.r/DAYSZweekdayr0MONTHSr(r'r)r1r2r3rrr
time2netscapejs
r8)ZGMTUTCZUTZz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTt|}|rfdt|d}|drR|dt|d}|ddkrf|}|S)Nr	ir<r-)	UTC_ZONESTIMEZONE_REsearchintgroup)tzoffsetmrrroffset_from_tz_strings

rFc
Cst|}|tjkrdSzt|d}Wn^tk
rzt|}Wntk
r`YYdSXd|krvdkrnn|}nYdSYnX|dkrd}|dkrd}|dkrd}t|}t|}t|}t|}|dkr6ttd}|d}	|}
|||	}|	|
}	t	|	dkr6|	dkr.|d}n|d}t
|||||||f}|dk	r|dkrdd}|}t|}|dkrdS||}|S)Nrr r	id2r9)
rAr-ZMAXYEARMONTHS_LOWERindexlower
ValueErrortime	localtimeabsr,upperrF)
r0monyrhrr*r+rCZimonZcur_yrrEZtmpr4rDrrr	_str2timesV







rTzV^[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*
    )?$cCst|}|rl|}t|dd}t|d|t|dt|dt|dt|df}t|S|	}t
d|d}dgd	\}}}}}}	}
t|}|dk	r|\}}}}}}	}
ndSt
||||||	|
S)
aReturns 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.

    rrr	r;N)STRICT_DATE_REr@groupsrIrJrKrAfloatr,lstrip
WEEKDAY_REsubLOOSE_HTTP_DATE_RErT)textrEgrQr&r0rRrSr*r+rCrrr	http2times$




rba^
    (\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
Csd|}dgd\}}}}}}}t|}|dk	rL|\}}}}}}}}	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

    NrX)r\ISO_DATE_REr@rZrT)
r`r0rQrRrSr*r+rCrE_rrriso2time+s

recCs*|d\}}|jd||j|dS)z)Return unmatched part of re.Match object.r	N)spanstring)matchstartendrrr	unmatchedLsrkz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}|D]}|}g}|rt|}|rt|}|d}t|}|rft|}|d}td|}n.t|}|rt|}|d}|}nd}|	||fq|
dr|
dd}|r|	|g}qt
dd|\}}	|}q|r|	|q|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"')]]

    rz\1N,z^[=\s;]*rW)HEADER_TOKEN_REr@rkrBHEADER_QUOTED_VALUE_REHEADER_ESCAPE_REr^HEADER_VALUE_RErstripappendr\
startswithresubn)
Z
header_valuesresultr`Z	orig_textpairsrEnamevalueZnon_junkZ
nr_junk_charsrrrsplit_header_wordsUs>.







rz([\"\\])cCs|g}|D]h}g}|D]F\}}|dk	rPtd|sDtd|}d|}d||f}||q|r|d|qd|S)aDo 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"%s=%s; , )rtr@HEADER_JOIN_ESCAPE_REr^rrjoin)Zlistsheadersrwattrkvrrrjoin_header_wordssrcCs0|dr|dd}|dr,|dd}|S)N"r)rsendswithr`rrrstrip_quotess


rcCsd}g}|D]}g}d}t|dD]\}}|}|d\}}	}
|}|sb|dkr&qnq&|	rn|
nd}
|dkr|}||kr|}|dkr|
dk	rt|
}
d}n|d	kr|
dk	rtt|
}
|||
fq&|r|s|d
||q|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.

    )expiresdomainpathsecureversionportmax-ageF;=r	NrTr)r0)	enumeratesplitstrip	partitionrKrrbrr)Z
ns_headersZknown_attrsrvZ	ns_headerrwversion_setZiiZparamkeysepvallcrrrparse_ns_headerss>
rz\.\d+$cCs:t|rdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrWr	.rTIPV4_REr@rrrris_HDNs
rcCsl|}|}||krdSt|s(dS||}|dksB|dkrFdS|dsTdSt|ddshdSdS)aReturn 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.

    TFrr	rrN)rKrrfindrs)ABirrrdomain_matchs

rcCst|rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FTrrrrrliberal_is_HDNFs
rcCs`|}|}t|r t|s0||kr,dSdS|d}|rL||rLdS|s\||kr\dSdS)z\For blocking/accepting domains.

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

    TFr)rKrrsr)rrinitial_dotrrruser_domain_matchPs
rz:\d+$cCsB|}tj|d}|dkr,|dd}td|d}|S)zReturn request-host, as defined by RFC 2965.

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

    rrWZHost)get_full_urlurllibparseZurlparseZ
get_headercut_port_rer^rK)requesturlhostrrrrequest_hostesrcCs4t|}}|ddkr,t|s,|d}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    rr.local)rfindrr@)rerhnreq_hostrrreff_request_hostusrcCs4|}tj|}t|j}|ds0d|}|S)z6Path component of request-URI, as defined by RFC 2965./)rrrZurlsplitescape_pathrrs)rrpartsrrrrrequest_paths

rcCs`|j}|d}|dkrX||dd}zt|Wq\tk
rTtd|YdSXnt}|S)N:r	rznonnumeric port: '%s')rrrArLrDEFAULT_HTTP_PORT)rrrrrrrrequest_ports


rz%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|dS)Nz%%%sr)rBrP)rhrrruppercase_escaped_charsrcCstj|t}tt|}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)rrZquoteHTTP_PATH_SAFEESCAPED_CHAR_REr^r)rrrrrs
rcCsP|d}|dkrL||dd}|d}t|rL|dksD|dkrLd|S|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'

    rr	rNZlocal)rr)hrbrrrreachs

rcCs$t|}t|t|jsdSdSdS)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.

    TFN)rrrZorigin_req_host)rrrrris_third_partys
rc@sNeZdZdZdddZddZddd	Zd
dZddd
ZddZ	ddZ
dS)raHTTP 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.

    FcCs|dk	rt|}|dk	r$tt|}|dkr<|dkr<td||_||_||_||_||_||_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_t||_dS)NTz-if port is None, port_specified must be false)rAr[rLrrxryrport_specifiedrKrdomain_specifieddomain_initial_dotrpath_specifiedrrdiscardcommentcomment_urlrfc2109copy_rest)selfrrxryrrrrrrrrrrrrrestrrrr__init__s.

zCookie.__init__cCs
||jkSNr)rrxrrrhas_nonstandard_attrszCookie.has_nonstandard_attrNcCs|j||Sr)rget)rrxdefaultrrrget_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dSrr)rrxryrrrset_nonstandard_attr szCookie.set_nonstandard_attrcCs,|dkrt}|jdk	r(|j|kr(dSdSNTF)rMr)rnowrrr
is_expired#s
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrWrr}z<Cookie %s for %s>)rrrryrx)rplimitZ	namevaluerrr__str__)s


zCookie.__str__cCslg}dD]$}t||}|d|t|fq|dt|j|dt|jd|jjd|fS)N)rrxryrrrrrrrrrrrrr}zrest=%sz
rfc2109=%sz%s(%s)r)getattrrrreprrr	__class____name__r)rrrxrrrr__repr__3s
zCookie.__repr__)F)N)N)r
__module____qualname____doc__rrrrrrrrrrrrs
*


c@s0eZdZdZddZddZddZdd	Zd
S)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 customized policy.

    cCs
tdS)zReturn 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.

        NNotImplementedErrorrcookierrrrset_okKszCookiePolicy.set_okcCs
tdS)zAReturn true if (and only if) cookie should be returned to server.Nrrrrr	return_okTszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr)rrrrrrdomain_return_okXszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path.
        Tr)rrrrrrpath_return_ok]szCookiePolicy.path_return_okN)rrrrrrrrrrrrrBs
	c
@seZdZdZdZdZdZdZeeBZdddddddddeddd	f
d
dZ	dd
Z
ddZddZddZ
ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7ZdS)8rzBImplements the standard rules for accepting and returning cookies.rrrUr	NTF)ZhttpsZwsscCsv||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|dk	rVt||_nd|_|dk	rlt|}||_
dS)zAConstructor arguments should be passed as keyword arguments only.Nr)netscaperfc2965rfc2109_as_netscapehide_cookie2
strict_domainstrict_rfc2965_unverifiablestrict_ns_unverifiablestrict_ns_domainstrict_ns_set_initial_dollarstrict_ns_set_pathsecure_protocolstuple_blocked_domains_allowed_domains)rblocked_domainsallowed_domainsrrrrrrrrrrrrrrrms"zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)rrrrrrsz#DefaultCookiePolicy.blocked_domainscCst||_dS)z$Set the sequence of blocked domains.N)rr)rrrrrset_blocked_domainssz'DefaultCookiePolicy.set_blocked_domainscCs |jD]}t||rdSqdSr)rr)rrZblocked_domainrrr
is_blockeds

zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)rrrrrrsz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|}||_dS)z-Set the sequence of allowed domains, or None.N)rr)rrrrrset_allowed_domainssz'DefaultCookiePolicy.set_allowed_domainscCs.|jdkrdS|jD]}t||rdSqdS)NFT)rr)rrZallowed_domainrrris_not_alloweds


z"DefaultCookiePolicy.is_not_allowedcCs@td|j|jdD]&}d|}t||}|||sdSqdS)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=%s)r
verifiabilityrxrrrZset_ok_FTrrxryrrrrnZfn_namefnrrrrs

zDefaultCookiePolicy.set_okcCsZ|jdkrtd|j|jdS|jdkr:|js:tddS|jdkrV|jsVtddSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	$   RFC 2965 cookies are switched off$   Netscape cookies are switched offT)rrrxryrrrrrrset_ok_versions
z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|rF|jdkr*|jr*tddS|jdkrF|jrFtddSdSNr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionTZunverifiablerrrrrrrrrset_ok_verifiabilitysz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|jdr,td|jdSdS)Nr	$z'   illegal name (starts with '$'): '%s'FT)rrrxrsrrrrrset_ok_names
zDefaultCookiePolicy.set_ok_namecCsL|jrHt|}|jdks(|jdkrH|jrH||j|sHtd|j|dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)rrrrrrr)rrrreq_pathrrrset_ok_paths
zDefaultCookiePolicy.set_ok_pathc
Cs||jrtd|jdS||jr8td|jdS|jrt|\}}|j}|jr|ddkr|d}|dd|}|dkr||dd}||d|}	|		dkrt
|dkrtd	|dS|dr|dd}
n|}
|
ddk}|s|d
krtd|dS|j
dkrX||sX|dsXd||sXtd||dS|j
dksr|j|j@rt||std
||dS|j
dks|j|j@r|dt
|}|ddkrt|std||dSdS)N"   domain %s is in user block-listF&   domain %s is not in user allow-listrrr	r)coZacZcomZeduZorgZnetZgovZmilrAZaeroZbizcatZcoopinfoZjobsZmobiZmuseumrxZproZtravelZeuz&   country-code second level domain %srz/   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)rrrrrrrcountrrKlenrsrrrrDomainRFC2965MatchrDomainStrictNoDotsrr@)
rrrrrrrjZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr
set_ok_domains|





z!DefaultCookiePolicy.set_ok_domainc	Cs|jrt|}|dkrd}nt|}|jdD]@}zt|Wn"tk
rbtd|YdSX||kr0qq0td||jdSdS)N80rlz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)rrstrrrrArLrrrrZreq_portrrrrset_ok_port+s&

zDefaultCookiePolicy.set_ok_portcCs@td|j|jdD]&}d|}t||}|||sdSqdS)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).

        r)rrrrrrZ
return_ok_FTrr	rrrr@s	

zDefaultCookiePolicy.return_okcCs<|jdkr|jstddS|jdkr8|js8tddSdS)Nr	rFr
T)rrrrrrrrreturn_ok_versionRsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|rF|jdkr*|jr*tddS|jdkrF|jrFtddSdSrrrrrrreturn_ok_verifiability[sz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jkrtddSdS)Nz(   secure cookie with non-secure requestFT)rtyperrrrrrreturn_ok_securegsz$DefaultCookiePolicy.return_ok_securecCs||jrtddSdS)Nz   cookie expiredFT)r_nowrrrrrreturn_ok_expiresmsz%DefaultCookiePolicy.return_ok_expirescCsN|jrJt|}|dkrd}|jdD]}||kr&qJq&td||jdSdS)Nr!rlz0   request port %s does not match cookie port %sFT)rrrrr#rrrreturn_ok_portssz"DefaultCookiePolicy.return_ok_portcCst|\}}|j}|r*|ds*d|}n|}|jdkr^|j|j@r^|js^||kr^tddS|jdkrt||std||dS|jdkrd|	|std||dSdS)Nrr	zQ   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 %sz;   request-host %s does not match Netscape cookie domain %sT)
rrrsrrDomainStrictNonDomainrrrr)rrrrrr	dotdomainrrrreturn_ok_domains6


z$DefaultCookiePolicy.return_ok_domaincCst|\}}|dsd|}|ds0d|}|rH|dsHd|}n|}||sd||sddS||r|td|dS||rtd|dSdS)NrFrrT)rrsrrrr)rrrrrr-rrrrs"






z$DefaultCookiePolicy.domain_return_okcCsbtd|t|}t|}||kr&dS||rR|dsN|||ddkrRdStd||dS)Nz- checking cookie path=%sTrrz  %s does not path-match %sF)rrrrsr)rrrrZpathlenrrrrs

z"DefaultCookiePolicy.path_return_ok) rrrrrr,rZ
DomainLiberalZDomainStrictrrrrrrrrrrrrr r$rr%r&r(r*r+r.rrrrrrrcsT
#	;	cCst|}t|j|Sr)sortedkeysmapr)Zadictr0rrrvals_sorted_by_keysr2c	csVt|}|D]D}d}z
|jWntk
r2YnXd}t|EdH|s|VqdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r2itemsAttributeError
deepvalues)mappingvaluesobjrrrr5s
r5c@seZdZdS)AbsentNrrrrrrrr9sr9c@seZdZdZedZedZedZedZ	edZ
edejZd3d	d
Z
ddZd
dZddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd4d%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Z d1d2Z!dS)5rzCollection 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+)NcCs(|dkrt}||_t|_i|_dSr)r_policy
_threadingRLock
_cookies_lock_cookiesrpolicyrrrrs

zCookieJar.__init__cCs
||_dSr)r;r@rrr
set_policyszCookieJar.set_policycCsg}|j||sgStd||j|}|D]T}|j||sFq2||}|D].}|j||srtdqVtd||qVq2|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r;rrr?r0rr7rrr)rrrcookiesZcookies_by_pathrZcookies_by_namerrrr_cookies_for_domains 

zCookieJar._cookies_for_domaincCs*g}|jD]}||||q|S)z2Return a list of cookies to be returned to server.)r?r0extendrD)rrrCrrrr_cookies_for_requestszCookieJar._cookies_for_requestc	Cs<|jddddd}g}|D]}|j}|sHd}|dkrH|d||jdk	rz|j|jrz|dkrz|jd	|j}n|j}|jdkr||jn|d
|j|f|dkr|j	r|d|j
|jdr|j}|j
s|dr|d
d}|d||jdk	rd}|jr,|d|j}||q|S)zReturn 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).

        cSs
t|jSr)rr)arrr<lambda>z)CookieJar._cookie_attrs.<locals>.<lambda>T)rreverseFr	z$Version=%sNr|r}z
$Path="%s"rrz$Domain="%s"z$Portz="%s")sortrrrrynon_word_rer@quote_rer^rxrrrrsrrr)	rrCrattrsrrryrrrrr
_cookie_attrssF




zCookieJar._cookie_attrscCstd|jztt|j_|_||}|	|}|r^|
ds^|dd||jj
r|jjs|
ds|D]}|jdkr||ddqq|W5|jX|dS)zAdd correct Cookie: header to request (urllib.request.Request object).

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

        add_cookie_headerrr~ZCookie2rz$Version="1"N)rr>acquirereleaserArMr;r)rFrOZ
has_headerZadd_unredirected_headerrrrrclear_expired_cookies)rrrCrNrrrrrPIs*





zCookieJar.add_cookie_headerc
Csg}d}d}|D]z}|d\}}d}d}	i}
i}|ddD]0\}}
|}||ks`||krd|}||krx|
dkrxd}
||
krq>|dkr|
dkrtd	d}	qr|
}
|d
kr|rq>|
dkrtdq>|dkr d}zt|
}
Wn*tk
rtd
d}	YqrYnXd
}|j|
}
||ks4||krh|
dkr^|dkr^td|d}	qr|
|
|<q>|
||<q>|	rzq||||
|fq|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)rrrrrrr
commenturlr	FrNTrz%   missing value for domain attributerzM   missing or invalid value for expires attribute: treating as session cookierz?   missing or invalid (non-numeric) value for max-age attribute)rrrTz!   missing value for %s attribute)rKrrArLr)rr)r	attrs_set
cookie_tuples
boolean_attrsvalue_attrsZcookie_attrsrxryZmax_age_setZ
bad_cookiestandardrrrrrrr_normalized_cookie_tuplesjsh







z#CookieJar._normalized_cookie_tuplescCs&|\}}}}|dt}|dt}|dt}	|dt}
|dd}|dk	rtzt|}Wntk
rrYdSX|dd}|dd}
|d	d}|d
d}|tk	r|dkrd}t|}nXd}t|}|d
}|dkr|dkr|d|}n|d|d}t|dkrd
}|tk	}d}|r:t|	d}|tkrVt
|\}}|}n|	dsjd|}d}|	tk	r|	dkrt|}	nd}t
dd|	}	nd}	|
tkrd}
d}
nH|
|jkrz||||Wntk
rYnXtd|||dSt||||	||||||||
|
|||S)NrrrrrrFrrrTrWTrrr	rrz\s+z2Expiring cookie, domain='%s', path='%s', name='%s')rr9rArLrrrrboolrsrrrtr^r)clearKeyErrorrr)rtuprrxryrYrrrrrrrrrrrrrrrrrrrr_cookie_from_cookie_tuples







z#CookieJar._cookie_from_cookie_tuplecCs6||}g}|D]}|||}|r||q|Sr)rZr_rr)rrUrrVrCr^rrrr_cookies_from_attrs_set's
z!CookieJar._cookies_from_attrs_setcCsHt|jdd}|dkr |jj}|D]}|jdkr$d|_|r$d|_q$dS)NrrTr	)rr;rrr)rrCZ
rfc2109_as_nsrrrr_process_rfc2109_cookies0s

z"CookieJar._process_rfc2109_cookiesc
Cs:|}|dg}|dg}tt|j_|_|jj}|jj}|sN|rf|sV|rf|s^|rf|sj|sjgSz|t	||}Wnt
k
rtg}YnX|r6|r6z|t||}	Wnt
k
rtg}	YnX|
|	|r&i}
|D]}d|
|j|j|jf<q|
fdd}t||	}	|	r6||	|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNcSs|j|j|jf}||kSr)rrrx)Z	ns_cookielookuprrrrno_matching_rfc2965isz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allrArMr;r)rrr`rz	ExceptionrrrarrrxfilterrE)
rresponserrZrfc2965_hdrsZns_hdrsrrrCZ
ns_cookiesrbrrcrrrmake_cookies<s^




zCookieJar.make_cookiescCsN|jz2tt|j_|_|j||r:||W5|jXdS)z-Set a cookie if policy says it's OK to do so.N)	r>rQrRrArMr;r)r
set_cookierrrrset_cookie_if_okss
zCookieJar.set_cookie_if_okcCsl|j}|jzJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<W5|jXdS)z?Set a cookie, without checking whether or not it should be set.N)r?r>rQrRrrrx)rrcZc2Zc3rrrrhs






zCookieJar.set_cookiecCsbtd||jz8|||D]&}|j||r&td|||q&W5|jXdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)	rrr>rQrRrgr;rrh)rrfrrrrrextract_cookiess

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td|j|||=n>|dk	rX|dkrJtd|j||=n|dk	rj|j|=ni|_dS)aClear 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)rLr?)rrrrxrrrr\s
zCookieJar.clearcCsD|jz(|D]}|jr||j|j|jqW5|jXdS)zDiscard 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>rQrRrr\rrrx)rrrrrclear_session_cookiess
zCookieJar.clear_session_cookiescCsP|jz4t}|D]"}||r||j|j|jqW5|jXdS)aDiscard 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>rQrRrMrr\rrrx)rrrrrrrSs


zCookieJar.clear_expired_cookiescCs
t|jSr)r5r?rrrr__iter__szCookieJar.__iter__cCsd}|D]}|d}q|S)z#Return number of contained cookies.r	rr)rrrrrr__len__s
zCookieJar.__len__cCs2g}|D]}|t|qd|jjd|fSNz<%s[%s]>r)rrrrrrrrrrrrrszCookieJar.__repr__cCs2g}|D]}|t|qd|jjd|fSro)rrr"rrrrprrrrszCookieJar.__str__)N)NNN)"rrrrrtcompilerLrMZstrict_domain_reZ	domain_reZdots_reASCIImagic_rerrBrDrFrOrPrZr_r`rargrirhrkr\rlrSrmrnrrrrrrrs8





;!a\	7


c@seZdZdS)rNr:rrrrrsc@s8eZdZdZdddZd
ddZddd	Zdd
dZdS)rz6CookieJar that can be loaded from and saved to a file.NFcCs2t|||dk	rt|}||_t||_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        N)rrosfspathfilenamer[	delayload)rrwrxrArrrrs

zFileCookieJar.__init__cCs
tdS)zSave cookies to a file.Nr)rrwignore_discardignore_expiresrrrsaveszFileCookieJar.savec	CsJ|dkr"|jdk	r|j}nttt|}|||||W5QRXdS)zLoad cookies from a file.N)rwrLMISSING_FILENAME_TEXTopen_really_loadrrwryrzrrrrloads

zFileCookieJar.loadcCs|dkr"|jdk	r|j}ntt|jzFt|j}i|_z|	|||Wnt
k
rn||_YnXW5|jXdS)zClear all cookies and reload cookies from a saved file.

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

        N)rwrLr|r>rQrRrZdeepcopyr?rOSError)rrwryrzZ	old_staterrrrevert	s

zFileCookieJar.revert)NFN)NFF)NFF)NFF)rrrrrr{rrrrrrrs


	cCs |j|jfd|jfd|jfg}|jdk	r8|d|jf|jrH|d|jrX|d|jrh|d|j	rx|d|j
r|d	tt|j
f|j
r|d
|jr|d|jf|jr|d|jft|j}|D]}||t|j|fq|d
t|jft|gS)zReturn string representation of Cookie in the LWP cookie file format.

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

    rrNr)	path_specN)	port_specN)
domain_dotN)rNr)rNrrTr)rxryrrrrrrrrrrr5r[rrrr/rr0r"rr)rrr0rrrrlwp_cookie_str$s:






rc@s,eZdZdZdddZdddZd	d
ZdS)
ra[
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl library, 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)

    TcCsTt}g}|D]2}|s |jr q|s0||r0q|dt|qd|dgS)zReturn cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s
rW)rMrrrrrr)rryrzrrqrrrr
as_lwp_strMs
zLWPCookieJar.as_lwp_strNFc	CsX|dkr"|jdk	r|j}nttt|d"}|d||||W5QRXdS)Nwz#LWP-Cookies-2.0
)rwrLr|r}writerrrrrr{]s

zLWPCookieJar.savecCs0|}|j|s$d|}t|t}d}d}	d}
z|}|dkrPq||s\q<|t|d}t|gD]f}|d\}
}i}i}|	D]}d||<q|ddD]n\}}|dk	r|	}nd}||
ks||	kr|}||	kr|dkrd	}|||<q||
kr|||<q|||<q|j
}|d
}|d}|dk	rJt|}|dkrXd	}|d}|d
}t|d|
||d|d|||d|d|d|d|||d|d|}|s|j
rqz|s||rqz||qzq<WnBtk
rYn,tk
r*ttd||fYnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)rrrrr)rrrrrrrTrWr	FrTrrrrrrrrrrrrrTz&invalid Set-Cookie3 format file %r: %r)readlinertr@rrMrsrrrzrKrrerrrrhrrdr)rrrwryrzmagicrrheaderrWrXlinedatarxryrYrrrrrrrrrrjrrrr~is











zLWPCookieJar._really_load)TT)NFF)rrrrrr{r~rrrrr@s

c@s0eZdZdZedZdZddZd
dd	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 Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsbt}|}|j|s(td|z|}|dkr>q|drT|dd}|ds*|dkrpq*|d\}}	}
}}}
}|dk}|	dk}	|
dkr|}
d}|d}d	}|dkrd}d
}t	d|
|dd	||	||
d	|||ddi}|s|j
rq*|s||rq*||q*WnBt
k
r2Yn,tk
r\ttd||fYnXdS)
Nz4%r does not look like a Netscape format cookies filerWrr)#r	TRUErFTr	z+invalid Netscape format cookies file %r: %r)rMrrtr@rrrrsrrrrrhrrdr)rrrwryrzrrrrrrrrrxryrrrjrrrr~sr




zMozillaCookieJar._really_loadNFc
Cs|dkr"|jdk	r|j}nttt|d}||jt}|D]}|sV|jrVqF|sf||rfqF|j	rrd}nd}|j
drd}nd}|jdk	rt
|j}	nd}	|jdkrd}
|j}n|j}
|j}|d|j
||j||	|
|gdqFW5QRXdS)NrrZFALSErrWrr)rwrLr|r}rrrMrrrrrsrr"ryrxrr)rrwryrzrrrrrrrxryrrrr{ sH



zMozillaCookieJar.save)NFF)
rrrrrtrrrtrr~r{rrrrrs

A)N)N)Xr__all__rurr-rtrMZurllib.parserZurllib.requestZ	threadingr<Zhttp.clientZhttpZcalendarr
rrrr"ZclientZ	HTTP_PORTrr|rr%r,r6r7rIr(rrrKr5r8r>rrrsr?rFrTrYIr]Xr_rbrcrerkrmrnrprorzrrrrrrrrrrrrrrrrrrrrrrrr2r5r9rrrrrrrrrrr<module>s


8

8
!



U
D'


#b!b7x

T1KUS90T
  root-grov@89.117.188.241:~$