§
    ;xÅjX?  ã                   ó¤  — d Z ddlZddlmZ ddlmZmZ ddlmZ dZ	 ej
        d¦  «        Z ed	¦  «        Z ed
¦  «        ZdZdZdZdZ ej
        dej        ¦  «        Z ej
        d¦  «        Z ej
        d¦  «        Z ej
        dej        ej        z  ¦  «        Zdee         dee         fd„Z ej
        d¦  «        j        Zdej        e         defd„Zdedefd„Zdede e!eee         f                  fd„Z"dede#dz  fd„Z$dee         d eddfd!„Z%dede!eee#f         dz  fd"„Z&d#ee         de e!eee         f                  fd$„Z'dS )%zµ
Internal cookie handling helpers.

This module contains internal utilities for cookie parsing and manipulation.
These are not part of the public API and may change without notice.
é    N)ÚSequence)ÚCookieErrorÚMorselé   )Úinternal_logger)Úparse_set_cookie_headersÚparse_cookie_headerÚ preserve_morsel_with_coded_valuez.^[!#$%&\'()*+\-./0-9:<=>?@A-Z\[\]^_`a-z{|}~]+$)
ÚpathÚdomainzmax-ageÚexpiresÚsecureÚhttponlyÚsamesiteÚpartitionedÚversionÚcomment)r   r   r   é2   i   i   é    z[^;\s]z[\x00-\x08\x0a-\x1f\x7f]z[\x00-\x1f\x7f]aà  
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    # aiohttp has extended to include [] for compatibility with real-world cookies
    [\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\[\]]+   # 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 double-quoted string (properly closed)
    |                                  # or
    "[^";]*                            # Unmatched opening quote (differs from SimpleCookie - issue #7993)
    |                                  # or
    # Special case for "expires" attr - RFC 822, RFC 850, RFC 1036, RFC 1123
    (\w{3,6}day|\w{3}),\s              # Day of the week or abbreviated day (with comma)
    [\w\d\s-]{9,11}\s[\d:]{8}\s        # Date and time in specific format
    (GMT|[+-]\d{4})                     # Timezone: GMT or RFC 2822 offset like -0000, +0100
                                        # NOTE: RFC 2822 timezone support is an aiohttp extension
                                        # for issue #4493 - SimpleCookie does NOT support this
    |                                  # or
    # ANSI C asctime() format: "Wed Jun  9 10:18:14 2021"
    # NOTE: This is an aiohttp extension for issue #4327 - SimpleCookie does NOT support this format
    \w{3}\s+\w{3}\s+[\s\d]\d\s+\d{2}:\d{2}:\d{2}\s+\d{4}
    |                                  # or
    [\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=\[\]]*      # 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.
    ÚcookieÚreturnc                 óš   — t          ¦   «         }	 |                     | j        | j        | j        dœ¦  «         n# t
          $ r | cY S w xY w|S )a^  
    Preserve a Morsel's coded_value exactly as received from the server.

    This function ensures that cookie encoding is preserved exactly as sent by
    the server, which is critical for compatibility with old servers that have
    strict requirements about cookie formats.

    This addresses the issue described in https://github.com/aio-libs/aiohttp/pull/1453
    where Python's SimpleCookie would re-encode cookies, breaking authentication
    with certain servers.

    Args:
        cookie: A Morsel object from SimpleCookie

    Returns:
        A Morsel object with preserved coded_value

    ©ÚkeyÚvalueÚcoded_value)r   Ú__setstate__r   r   r   r   )r   Úmrsl_vals     úHC:\Projects\Historical\venv\Lib\site-packages\aiohttp/_cookie_helpers.pyr
   r
   `   st   € õ* #™HœH€Hð
	Ø×Òà”zØœØ%Ô1ðð ñ	
ô 	
ð 	
ð 	
øõ ð ð ð Øˆˆˆðøøøà€Os   �(9 ¹AÁAz\\(?:([0-3][0-7][0-7])|(.))Úmc                 óh   — | d         r#t          t          | d         d¦  «        ¦  «        S | d         S )zþ
    Replace function for _unquote_sub regex substitution.

    Handles escaped characters in cookie values:
    - Octal sequences are converted to their character representation
    - Other escaped characters are unescaped by removing the backslash
    r   é   é   )ÚchrÚint)r    s    r   Ú_unquote_replacer&   Š   s3   € ð 	ˆ„tð !Ý•3�q˜”t˜Q‘<”<Ñ Ô Ð ØˆQŒ4€Kó    r   c                 óž   — t          | ¦  «        dk     r| S | d         dk    s| d         dk    r| S | dd…         } t          t          | ¦  «        S )zõ
    Unquote a cookie value.

    Vendored from http.cookies._unquote to ensure compatibility.

    Note: The original implementation checked for None, but we've removed
    that check since all callers already ensure the value is not None.
    r#   r   ú"éÿÿÿÿr   )ÚlenÚ_unquote_subr&   )r   s    r   Ú_unquoter-   —   sZ   € õ ˆ5�z„z�A‚~€~ØˆØˆQ„x�3‚€˜% œ) sÒ*Ð*Øˆð �!�B�$ŒK€Eõ Õ(¨%Ñ0Ô0Ð0r'   Úheaderc                 ó   — | sg S g }d}t          | ¦  «        }g }||k     �rt                               | |¦  «        }|�s|                      d|¦  «        }|                      d|¦  «        }|dk    rÞ|dk    s||k     rÒ|dk    r|n|}| ||…                              ¦   «         }	| |dz   |…                              ¦   «         }
t
                               |	¦  «        s|                     |	¦  «         n]t          ¦   «         }	 |                     |	t          |
¦  «        |
dœ¦  «         |                     |	|f¦  «         n# t          $ r Y nw xY w|dk    r|dz   n|}�ŒD|                     d¦  «        }	|                     d¦  «        pd	}
|                     d¦  «        }|	rt
                               |	¦  «        s|                     |	¦  «         �Œ¸t          ¦   «         }	 |                     |	t          |
¦  «        |
dœ¦  «         n# t          $ r Y �Œûw xY w|                     |	|f¦  «         ||k     �°|rt          j        d
|¦  «         |S )aÙ  
    Parse a Cookie header according to RFC 6265 Section 5.4.

    Cookie headers contain only name-value pairs separated by semicolons.
    There are no attributes in Cookie headers - even names that match
    attribute names (like 'path' or 'secure') should be treated as cookies.

    This parser uses _COOKIE_PATTERN to properly handle quoted values that may
    contain semicolons. When the regex fails to match a malformed cookie, it
    falls back to simple parsing to ensure subsequent cookies are not lost
    https://github.com/aio-libs/aiohttp/issues/11632

    Args:
        header: The Cookie header value to parse

    Returns:
        List of (name, Morsel) tuples for compatibility with SimpleCookie.update()
    r   ú;ú=r*   r   r   r   ÚvalÚ z,Cannot load cookie. Illegal cookie names: %r)r+   Ú_COOKIE_PATTERNÚmatchÚfindÚstripÚ_COOKIE_NAME_REÚappendr   r   r-   r   ÚgroupÚendr   Údebug)r.   ÚcookiesÚiÚnÚinvalid_namesr5   Ú	next_semiÚeq_posÚend_posr   r   Úmorsels               r   r	   r	   ´   sÃ  € ð& ð Øˆ	à-/€Gà	€AÝˆF‰Œ€Aà€MØ
ˆaŠ%‰%å×%Ò% f¨aÑ0Ô0ˆØñ  	ð Ÿš C¨Ñ+Ô+ˆIØ—[’[  aÑ(Ô(ˆFð ˜Š|ˆ| ¨b¢ °F¸YÒ4FÐ4FØ'0°B¢ ˜)˜)¸A�Ø˜Q˜v˜XÔ&×,Ò,Ñ.Ô.�Ø˜v¨™z¨GÐ3Ô4×:Ò:Ñ<Ô<�õ '×,Ò,¨SÑ1Ô1ð 6Ø!×(Ò(¨Ñ-Ô-Ð-Ð-å#™XœX�Fð6Ø×+Ò+à'*Ý)1°%©¬Ø/4ðð ñô ð ð  Ÿš¨¨V }Ñ5Ô5Ð5Ð5øõ 'ð ð ð Ø˜ðøøøð "+¨b¢ �	˜A‘�°aˆAÙà�kŠk˜%Ñ Ô ˆØ—’˜EÑ"Ô"Ð( bˆØ�IŠI�a‰LŒLˆð ð 	�/×/Ò/°Ñ4Ô4ð 	Ø× Ò  Ñ%Ô%Ð%Ùõ ‘”ˆð	Ø×ÒØ¥h¨u¡o¤oÀeÐLÐLñô ð ð øõ ð 	ð 	ð 	Ø‰Hð	øøøð 	�Š˜˜V�}Ñ%Ô%Ð%ðy ˆaŠ%‰%ð| ð 
ÝÔØ:¸Mñ	
ô 	
ð 	
ð €Ns$   Ä&D? Ä?
EÅEÇ!&H È
HÈHÚtextc                 ó°   — |                       ¦   «         rt          | ¦  «        S 	 t          |                      d¦  «        ¦  «        S # t          $ r Y dS w xY w)z@Return the UTF-8 length of text, or None if it can't be encoded.zutf-8N)Úisasciir+   ÚencodeÚUnicodeEncodeError)rE   s    r   Ú_encoded_lengthrJ     s_   € à‡|‚|�~„~ð Ý�4‰yŒyÐðÝ�4—;’;˜wÑ'Ô'Ñ(Ô(Ð(øÝð ð ð Øˆtˆtðøøøs   ¥!A Á
AÁArD   Ú
attributesc                 óÜ  — d}t          |¦  «        }t          t          ¦  «        D �]Ä}||k    r dS t                               ||¦  «        x}€P|                     d|¦  «        dz   x}rt                               ||¦  «        x}€ dS |                     ¦   «         }Œy| 	                    ¦   «         }| 
                    d¦  «                             ¦   «         }|t          vrŒ¾|| j        vrŒÈ|t          v rt                               | |d¦  «         Œî| 
                    d¦  «        pd}	t          |	¦  «        t"          k    rD|	                     ¦   «         r0|	dd…         d	k    r"d
|	vrt                               | ||	¦  «         �Œat'          |	¦  «        }
|
�|
t"          k    r�Œt(                               t+          |	¦  «        x}¦  «        €t                               | ||¦  «         �ŒÆdS )z‘Set the recognized attributes from the text after the cookie-pair.

    The field must already be free of control characters other than tab.
    r   Nr0   r   r   Tr2   r3   r)   ú	)r+   ÚrangeÚ_MAX_COOKIE_ATTRIBUTESr4   r5   r6   Ú_ATTRIBUTE_START_REÚsearchÚstartr;   r:   ÚlowerÚ_COOKIE_KNOWN_ATTRSÚ	_reservedÚ_COOKIE_BOOL_ATTRSÚdictÚ__setitem__Ú"_MAX_COOKIE_ATTRIBUTE_VALUE_LENGTHrG   rJ   Ú_COOKIE_CTL_REr-   )rD   rK   Úindexr;   Ú_Úattribute_matchÚ
next_indexrR   Ú	lower_keyÚ
attr_valueÚattr_value_lengthr   s               r   Ú_apply_cookie_attributesrb      s  € ð €EÝ
ˆj‰/Œ/€CÝÕ)Ñ*Ô*ð -7ñ -7ˆØ�CŠ<ˆ<ØˆEˆEÝ.×4Ò4°ZÀÑGÔGÐGˆOÐPð $.§?¢?°3¸Ñ#>Ô#>ÀÑ#BÐB�Zðå0×7Ò7¸
ÀJÑOÔOÐO�EÐXà��Ø—K’K‘M”MˆEØØ×#Ò#Ñ%Ô%ˆØ#×)Ò)¨%Ñ0Ô0×6Ò6Ñ8Ô8ˆ	ØÕ/Ð/Ð/àØ˜FÔ,Ð,Ð,àð Õ*Ð*Ð*å×Ò˜V Y°Ñ5Ô5Ð5ØØ$×*Ò*¨5Ñ1Ô1Ð7°Rˆ
å�
‰OŒOÕAÒAÐAØ×"Ò"Ñ$Ô$ð Bà˜2˜A˜2” #Ò%Ð%Ø˜JÐ&Ð&õ ×Ò˜V Y°
Ñ;Ô;Ð;ÙÝ+¨JÑ7Ô7ÐàÐ%Ø Õ#EÒEÐEáõ × Ò ­(°:Ñ*>Ô*>Ð!> Ñ?Ô?ÐGÝ×Ò˜V Y°Ñ6Ô6Ð6ùð[-7ð -7r'   c                 óè  — t                                | ¦  «        }|�|                     d¦  «        x}sdS |                     d¦  «        r|                     d¦  «        rd|v sdS | |                     d¦  «        d…                              d¦  «        }|r|                     d¦  «        sdS |                     d¦  «        |t          | ¦  «        t          |¦  «        z
  t          |¦  «        z   fS )zÒParse a first pair whose quoted value contains ";".

    aiohttp has always accepted these. Returns the name, the quoted value and
    where the attributes start, or None to split at the first ";" instead.
    Nr2   r)   r0   ú 	r   )	r4   r5   r:   Ú
startswithÚendswithr;   Úlstripr+   Úbool)r.   r5   r   Útails       r   Ú_parse_quoted_pairrj   Z  së   € õ ×!Ò! &Ñ)Ô)€EØ€} e§k¢k°%Ñ&8Ô&8Ð8˜U€}ØˆtØ×Ò˜SÑ!Ô!ð  e§n¢n°SÑ&9Ô&9ð ¸cÀU¸l¸lØˆtØ�%—)’)˜EÑ"Ô"Ð$Ð$Ô%×,Ò,¨UÑ3Ô3€DØð �D—O’O CÑ(Ô(ð ØˆtØ�;Š;�uÑÔ˜u¥c¨&¡k¤kµC¸±I´IÑ&=ÅÀTÁ
Ä
Ñ&JÐJÐJr'   Úheadersc                 óŽ  — g }d}t          | ¦  «        D �]í\  }}t          |¦  «        t          k    rt          | ¦  «        |z
  } �n¼|rt                               |¦  «        �ŒP|                     d¦  «        x}dk    rt          |¦  «        x}}n|dz   }|                     dd|¦  «        dk    rt          |¦  «        x}r|\  }}	}n$|d|…                              d¦  «        \  }}
}	|
sŒÙ|                     d¦  «        }|	                     d¦  «        }	|s�Œt           
                    |¦  «        st          j        d	|¦  «         �Œ8t          ||	z   ¦  «        }|�|t          k    r�ŒYt          |	¦  «        }t                                |¦  «        ��Œ„t#          ¦   «         }	 |                     |||	d
œ¦  «         n# t&          $ r Y �Œºw xY wt)          |||d…         ¦  «         |                     ||f¦  «         �Œït          | ¦  «        |z
  t          |¦  «        z
  x}s|rt          j        d||t          ¦  «         |S )zÃParse Set-Cookie fields into at most one cookie per field.

    Fields with control characters, oversized or nameless pairs, names outside
    the allowlist, or tabs in the pair are skipped.
    r   Nr0   r*   r   r)   r1   rd   z,Can not load cookies: Illegal cookie name %rr   zFIgnored %d invalid Set-Cookie field(s) and %d over the %d-cookie limit)Ú	enumerater+   Ú_MAX_COOKIES_PER_RESPONSEÚ_COOKIE_FORBIDDEN_CTL_RErQ   r6   rj   Ú	partitionr7   r8   r5   r   ÚwarningrJ   Ú_MAX_COOKIE_PAIR_LENGTHr-   rZ   r   r   r   rb   r9   r<   )rk   Úparsed_cookiesÚ
over_limitÚpositionr.   Úpair_endÚattributes_startÚquotedr   r   ÚsepÚpair_lengthr   rD   Úinvalids                  r   r   r   k  s«  € ð 57€NØ€Jå% gÑ.Ô.ð --ñ --Ñˆ�&Ýˆ~ÑÔÕ";Ò;Ð;Ý˜W™œ¨Ñ0ˆJØ‰EØð 	Õ1×8Ò8¸Ñ@Ô@ÐLØàŸš CÑ(Ô(Ð(ˆH¨RÒ/Ð/Ý*-¨f©+¬+Ð5ˆHÐ'Ð'à'¨!™|Ðà�;Š;�s˜A˜xÑ(Ô(¨BÒ.Ð.Ý(¨Ñ0Ô0Ð0ˆFð /ð 28Ñ.ˆC�Ð.Ð.à$*¨9¨H¨9Ô$5×$?Ò$?ÀÑ$DÔ$DÑ!ˆC��kØð Øà�iŠi˜ÑÔˆØ!×'Ò'¨Ñ.Ô.ˆàð 	ÙÝ×$Ò$ SÑ)Ô)ð 	ÝÔ#Ð$RÐTWÑXÔXÐXÙÝ% c¨KÑ&7Ñ8Ô8ˆØÐ +Õ0GÒ"GÐ"GÙå˜Ñ%Ô%ˆÝ× Ò  Ñ'Ô'Ð3ÙÝ$™hœhˆð	Ø×ÒØ e¸KÐHÐHñô ð ð øõ ð 	ð 	ð 	Ø‰Hð	øøøõ 	! ¨Ð0@Ð0AÐ0AÔ)BÑCÔCÐCØ×Ò˜s F˜mÑ,Ô,Ð,Ñ,å�w‘<”< *Ñ,­s°>Ñ/BÔ/BÑBÐBˆð 
Àzð 
ÝÔØTØØÝ%ñ		
ô 	
ð 	
ð Ðs   Æ'GÇ
GÇG)(Ú__doc__ÚreÚcollections.abcr   Úhttp.cookiesr   r   Úlogr   Ú__all__Úcompiler8   Ú	frozensetrT   rV   rn   rr   rY   rO   ÚASCIIrP   ro   rZ   ÚVERBOSEr4   Ústrr
   Úsubr,   ÚMatchr&   r-   ÚlistÚtupler	   r%   rJ   rb   rj   r   © r'   r   ú<module>rŒ      s¶  ððð ð 
€	€	€	Ø $Ð $Ð $Ð $Ð $Ð $Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à  Ð  Ð  Ð  Ð  Ð  ð€ð �"”*ÐNÑOÔO€Ø�iðñô Ð ð �YØ)ñô Ð ð
 Ð ØÐ Ø%)Ð "àÐ ð !�b”j ¨B¬HÑ5Ô5Ð Ø%˜2œ:Ð&AÑBÔBÐ Ø�”Ð.Ñ/Ô/€ð
 �"”*ðð< „J�”Ññ? ô  €ðF$¨V°C¬[ð $¸VÀC¼[ð $ð $ð $ð $ðN ˆrŒzÐ8Ñ9Ô9Ô=€ð
˜œ œð 
¨#ð 
ð 
ð 
ð 
ð1�Cð 1˜Cð 1ð 1ð 1ð 1ð:_ ð _¨¨U°3¸¸s¼Ð3CÔ-DÔ(Eð _ð _ð _ð _ðD˜#ð  #¨¡*ð ð ð ð ð77 V¨C¤[ð 77¸cð 77Àdð 77ð 77ð 77ð 77ðtK˜sð K u¨S°#°s¨]Ô';¸dÑ'Bð Kð Kð Kð Kð"? h¨s¤mð ?¸¸UÀ3ÈÈsÌÐCSÔ=TÔ8Uð ?ð ?ð ?ð ?ð ?ð ?r'   