3 0f Q @sxddlZddlZdddgZdjZdjZdjZdd ZGd ddeZ ej ej d Z e d Z d deedeeee DZejeddeddiejdeje jZddZejdjZddZddZddddd d!d"gZdd#d$d%d&d'd(d)d*d+d,d-d.g Zdeefd/d0ZGd1d2d2e Z!d3Z"e"d4Z#ejd5e"d6e#d7ej$ej%BZ&Gd8dde Z'Gd9dde'Z(dS):N 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])|(.))cCs&|drtt|ddS|dSdS)N)chrint)mrrr_unquote_replacesr%cCsJ|dkst|dkr|S|ddks0|ddkr4|S|dd}tt|S)Nr!rrrr&)len _unquote_subr%)rrrr_unquotes  r)ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc CsRddlm}m}|}|||\ }}}} } } } } }d|| ||||| | | fS)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r+r*)ZfutureZ weekdaynameZ monthnamer*r+ZnowZyearZmonthZdayZhhZmmZssZwdyzrrr_getdates r.c @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)r0pathcommentZdomainzmax-agesecurehttponlyversionr4r5cCs4d|_|_|_x|jD]}tj||dqWdS)Nr)_key_value _coded_value _reserveddict __setitem__)selfkeyrrr__init__s zMorsel.__init__cCs|jS)N)r7)r=rrrr>sz Morsel.keycCstd||_dS)Nr>)rr7)r=r>rrrr> scCs|jS)N)r8)r=rrrvalue%sz Morsel.valuecCstd||_dS)Nr@)rr8)r=r@rrrr@)scCs|jS)N)r9)r=rrr coded_value.szMorsel.coded_valuecCstd||_dS)NrA)rr9)r=rArrrrA2scCs2|j}||jkr td|ftj|||dS)NzInvalid attribute %r)lowerr:rr;r<)r=KVrrrr<7s zMorsel.__setitem__NcCs.|j}||jkr td|ftj|||S)NzInvalid attribute %r)rBr:rr; setdefault)r=r>valrrrrE=s zMorsel.setdefaultcCs>t|tstStj||o<|j|jko<|j|jko<|j|jkS)N) isinstancer/NotImplementedr;__eq__r8r7r9)r=morselrrrrICs     z Morsel.__eq__cCs$t}tj|||jj|j|S)N)r/r;update__dict__)r=rJrrrcopyMs z Morsel.copycCsVi}x@t|jD]0\}}|j}||jkr:td|f|||<qWtj||dS)NzInvalid attribute %r)r;itemsrBr:rrK)r=valuesdatar>rFrrrrKSs  z Morsel.updatecCs|j|jkS)N)rBr:)r=rCrrr isReservedKey\szMorsel.isReservedKeycCsh|tkr ddl}|jdtdd|j|jkrrFZ coded_valZ LegalCharsr rrrset_sz Morsel.setcCs|j|j|jdS)N)r>r@rA)r7r8r9)r=rrr __getstate__qszMorsel.__getstate__cCs"|d|_|d|_|d|_dS)Nr>r@rA)r7r8r9)r=staterrr __setstate__xs  zMorsel.__setstate__ Set-Cookie:cCsd||j|fS)Nz%s %s) OutputString)r=attrsheaderrrroutput}sz Morsel.outputcCsd|jj|jfS)Nz<%s: %s>) __class__rrX)r=rrr__repr__szMorsel.__repr__cCsd|j|jddS)Nz rz\")rXreplace)r=rYrrr 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=%srr0zmax-agez%s=%dr3) appendr>rAr:sortedrNrGr#r.rr_flags_semispacejoin)r=rYresultr`rNr>r@rrrrXs,  zMorsel.OutputString)N)NrW)N)N)rrrr:rbr?propertyr>r r@rAr<rErIobject__ne__rMrKrQrRrSrTrVr[__str__r]r_rXrrrrr/s>        r/z,\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)r=rFrrr value_decodeszBaseCookie.value_decodecCst|}||fS)N)r)r=rFstrvalrrr value_encodeszBaseCookie.value_encodeNcCs|r|j|dS)N)load)r=inputrrrr?szBaseCookie.__init__cCs.|j|t}|j|||tj|||dS)N)getr/rSr;r<)r=r>Z real_valuerAMrrrZ__setszBaseCookie.__setcCs:t|trtj|||n|j|\}}|j|||dS)N)rGr/r;r<rk_BaseCookie__set)r=r>r@rvalcvalrrrr<s zBaseCookie.__setitem__ Set-Cookie: cCs>g}t|j}x"|D]\}}|j|j||qW|j|S)N)rarNr`r[join)r=rYrZseprdrNr>r@rrrr[s  zBaseCookie.outputcCsNg}t|j}x(|D] \}}|jd|t|jfqWd|jjt|fS)Nz%s=%sz<%s: %s>)rarNr`reprr@r\r _spacejoin)r=lrNr>r@rrrr]s  zBaseCookie.__repr__cCs:g}t|j}x |D]\}}|j|j|qWt|S)N)rarNr`r_ _nulljoin)r=rYrdrNr>r@rrrr_ s  zBaseCookie.js_outputcCs8t|tr|j|nx|jD]\}}|||<q WdS)N)rGr_BaseCookie__parse_stringrN)r=Zrawdatar>r@rrrrls    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) NrFrr!r>rF$T) r'matchgroupendr`rBr/r:rbr)rirp)r=rZpattirZ parsed_itemsZ morsel_seenZTYPE_ATTRIBUTEZ TYPE_KEYVALUEr}r>r@rotprqrrrrrZ__parse_string"sF      zBaseCookie.__parse_string)N)Nrsrt)N)rrrrirkr?rpr<r[rhr]r_rl_CookiePatternr{rrrrrs    c@seZdZddZddZdS)rcCs t||fS)N)r))r=rFrrrrifszSimpleCookie.value_decodecCst|}|t|fS)N)rr)r=rFrjrrrrkiszSimpleCookie.value_encodeN)rrrrirkrrrrr_s))restring__all__rurzrcrxr ExceptionrZ ascii_lettersZdigitsrRZ_UnescapedCharsrSrangemapordrrKcompileescape fullmatchrrsubr(r%r)Z _weekdaynameZ _monthnamer.r;r/Z_LegalKeyCharsZ_LegalValueCharsASCIIVERBOSErrrrrrrsD    J