3 \S @sxddlZddlZdddgZdjZdjZdjZdd ZGd ddeZ ej ej d Z e d Z d deedeeee DZejeddeddiejdeje jZddZejdZejdZddZdddddd d!gZdd"d#d$d%d&d'd(d)d*d+d,d-g Zdeefd.d/ZGd0d1d1eZ d2Z!e!d3Z"ejd4e!d5e"d6ej#ej$BZ%Gd7ddeZ&Gd8dde&Z'dS)9N CookieError BaseCookie SimpleCookiez;  cCs$ddl}d|}|j|tdddS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead.) stacklevel)warningswarnDeprecationWarning)setterr msgr$/usr/lib64/python3.6/http/cookies.py_warn_deprecated_settersrc@s eZdZdS)rN)__name__ __module__ __qualname__rrrrrsz!#$%&'*+-.^_`|~:z ()/<=>?@[]{}cCsi|]}d||qS)z\%03or).0nrrr sr"z\"\z\\z[%s]+cCs*|dkst|r|Sd|jtdSdS)Nr) _is_legal_key translate _Translator)strrrr_quotesrz\\[0-3][0-7][0-7]z[\\].cCsT|dkst|dkr|S|ddks0|ddkr4|S|dd}d}t|}g}xd|kod|knrJtj||}tj||}| r| r|j||dPd }}|r|jd}|r|jd}|o| s||kr |j||||j||d|d}qR|j||||jtt||d|dd|d}qRWt|S) Nrrr#r#) len _OctalPattsearch _QuotePattappendstartchrint _nulljoin)rirresZo_matchZq_matchjkrrr_unquotes6       $ r1ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc CsRddlm}m}|}|||\ }}}} } } } } }d|| ||||| | | fS)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r3r2)ZfutureZ weekdaynameZ monthnamer2r3ZnowZyearZmonthZdayZhhZmmZssZwdyzrrr_getdates r6c @seZdZddddddddd Zd d hZd d ZeddZejddZeddZ e jddZ eddZ e jddZ ddZ d3ddZ ddZ ejZddZd d!Zd"d#Zefd$d%Zd&d'Zd(d)Zd4d+d,ZeZd-d.Zd5d/d0Zd6d1d2ZdS)7MorselexpiresZPathCommentZDomainzMax-AgeZSecureZHttpOnlyZVersion)r8pathcommentZdomainzmax-agesecurehttponlyversionr<r=cCs4d|_|_|_x|jD]}tj||dqWdS)Nr)_key_value _coded_value _reserveddict __setitem__)selfkeyrrr__init__&s zMorsel.__init__cCs|jS)N)r?)rErrrrF.sz Morsel.keycCstd||_dS)NrF)rr?)rErFrrrrF2scCs|jS)N)r@)rErrrvalue7sz Morsel.valuecCstd||_dS)NrH)rr@)rErHrrrrH;scCs|jS)N)rA)rErrr coded_value@szMorsel.coded_valuecCstd||_dS)NrI)rrA)rErIrrrrIDscCs2|j}||jkr td|ftj|||dS)NzInvalid attribute %r)lowerrBrrCrD)rEKVrrrrDIs zMorsel.__setitem__NcCs.|j}||jkr td|ftj|||S)NzInvalid attribute %r)rJrBrrC setdefault)rErFvalrrrrMOs zMorsel.setdefaultcCs>t|tstStj||o<|j|jko<|j|jko<|j|jkS)N) isinstancer7NotImplementedrC__eq__r@r?rA)rEmorselrrrrQUs     z Morsel.__eq__cCs$t}tj|||jj|j|S)N)r7rCupdate__dict__)rErRrrrcopy_s z Morsel.copycCsVi}x@t|jD]0\}}|j}||jkr:td|f|||<qWtj||dS)NzInvalid attribute %r)rCitemsrJrBrrS)rEvaluesdatarFrNrrrrSes  z Morsel.updatecCs|j|jkS)N)rJrB)rErKrrr isReservedKeynszMorsel.isReservedKeycCsh|tkr ddl}|jdtdd|j|jkr) __class__rr`)rErrr__repr__szMorsel.__repr__cCsd|j|jddS)Nz rz\")r`replace)rErarrr js_outputszMorsel.js_outputcCs(g}|j}|d|j|jf|dkr,|j}t|j}x|D]\}}|dkrPq>||krZq>|dkrt|tr|d|j|t|fq>|dkrt|tr|d|j||fq>|dkrt|t r|d|j|t |fq>||j kr|r|t |j|q>|d|j||fq>Wt |S)Nz%s=%srr8zmax-agez%s=%dr;) r(rFrIrBsortedrVrOr+r6rr_flags_semispacejoin)rEraresultr(rVrFrHrrrr`s,  zMorsel.OutputString)N)Nr_)N)N)rrrrBrirGpropertyrFr rHrIrDrMrQobject__ne__rUrSrYrZr[r\r^rc__str__rergr`rrrrr7s>        r7z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z \s* # Optional whitespace at start of cookie (?P # 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 # 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@sjeZdZddZddZdddZdd Zd d ZdddZeZ ddZ dddZ ddZ e fddZdS)rcCs||fS)Nr)rErNrrr value_decodeszBaseCookie.value_decodecCst|}||fS)N)r)rErNstrvalrrr value_encodeszBaseCookie.value_encodeNcCs|r|j|dS)N)load)rEinputrrrrGszBaseCookie.__init__cCs.|j|t}|j|||tj|||dS)N)getr7r[rCrD)rErFZ real_valuerIMrrrZ__setszBaseCookie.__setcCs:t|trtj|||n|j|\}}|j|||dS)N)rOr7rCrDrr_BaseCookie__set)rErFrHrvalcvalrrrrDs zBaseCookie.__setitem__ Set-Cookie: cCs>g}t|j}x"|D]\}}|j|j||qW|j|S)N)rhrVr(rcjoin)rErarbseprkrVrFrHrrrrc s  zBaseCookie.outputcCsNg}t|j}x(|D] \}}|jd|t|jfqWd|jjt|fS)Nz%s=%sz<%s: %s>)rhrVr(reprrHrdr _spacejoin)rElrVrFrHrrrres  zBaseCookie.__repr__cCs:g}t|j}x |D]\}}|j|j|qWt|S)N)rhrVr(rgr,)rErarkrVrFrHrrrrgs  zBaseCookie.js_outputcCs8t|tr|j|nx|jD]\}}|||<q WdS)N)rOr_BaseCookie__parse_stringrV)rEZrawdatarFrHrrrrs&s    zBaseCookie.loadcCspd}t|}g}d}d}d}xd|ko2|knr|j||} | sLP| jd| jd} } | jd}| ddkr|s~q |j|| dd| fq | jtjkr|sdS| dkr| jtjkr|j|| dfqdSn|j|| t | fq | dk r|j|| |j | fd}q dSq Wd} xF|D]>\} } } | |krH| | | <n| \}}|j | |||| } q*WdS) NrFr rrFrN$T) r$matchgroupendr(rJr7rBrir1rprw)rErZpattr-rZ parsed_itemsZ morsel_seenZTYPE_ATTRIBUTEZ TYPE_KEYVALUErrFrHrvtprxryrrrZ__parse_string4sF      zBaseCookie.__parse_string)N)Nrzr{)N)rrrrprrrGrwrDrcrorergrs_CookiePatternrrrrrrs    c@seZdZddZddZdS)rcCs t||fS)N)r1)rErNrrrrpxszSimpleCookie.value_decodecCst|}|t|fS)N)rr)rErNrqrrrrr{szSimpleCookie.value_encodeN)rrrrprrrrrrrqs)(restring__all__r|r,rjrr ExceptionrZ ascii_lettersZdigitsrZZ_UnescapedCharsr[rangemapordrrScompileescape fullmatchrrr%r'r1Z _weekdaynameZ _monthnamer6rCr7Z_LegalKeyCharsZ_LegalValueCharsASCIIVERBOSErrrrrrrsD    2 J