Your IP : 18.188.218.219
o
6��fƢ � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z
ddlmZ ddlmZ e
d�Zee
d �B Ze
d
�ZeeB Zee
d� Zee
d� Zee
d
�B e
d� ZeeB Zee
d�B ZeeB Zee
d� ZddhZeeB Zdd� Ze�dejejB �ZG dd� de �Z!G dd� de!�Z"G dd� de!�Z#G dd� de!�Z$G dd� de!�Z%G dd � d e"�Z&G d!d"� d"e!�Z'G d#d$� d$e!�Z(G d%d&� d&e!�Z)G d'd(� d(e!�Z*G d)d*� d*e*�Z+G d+d,� d,e"�Z,G d-d.� d.e!�Z-G d/d0� d0e!�Z.G d1d2� d2e!�Z/G d3d4� d4e!�Z0G d5d6� d6e!�Z1G d7d8� d8e!�Z2G d9d:� d:e!�Z3G d;d<� d<e!�Z4G d=d>� d>e!�Z5G d?d@� d@e!�Z6G dAdB� dBe!�Z7G dCdD� dDe!�Z8G dEdF� dFe!�Z9G dGdH� dHe!�Z:G dIdJ� dJe!�Z;G dKdL� dLe!�Z<G dMdN� dNe$�Z=G dOdP� dPe!�Z>G dQdR� dRe!�Z?G dSdT� dTe!�Z@G dUdV� dVe!�ZAG dWdX� dXeA�ZBG dYdZ� dZe!�ZCG d[d\� d\e!�ZDG d]d^� d^e!�ZEG d_d`� d`e!�ZFG dadb� dbe!�ZGG dcdd� ddeG�ZHG dedf� dfeG�ZIG dgdh� dhe!�ZJG didj� dje!�ZKG dkdl� dle!�ZLG dmdn� dneL�ZMG dodp� dpeM�ZNG dqdr� dre!�ZOG dsdt� dteP�ZQG dudv� dveQ�ZRG dwdx� dxeQ�ZSG dydz� dzeR�ZTG d{d|� d|ejU�ZVeSdd}�ZWeSd~d�ZXeSd�d��ZYe�d��Zd��[e���j\Z]e�d��Ze�^d��[e����j_Z`e�d��jaZbe�d��Ze�^d��[e����j_Zce�d��Ze�^d��[e����j_Zde�d��Ze�^d��[e����j_Zed�d�� Zfd�d�� Zgd�d�� Zhd�d�� Zid�d�� Zjd�d�� Zkd�d�� Zld�d�� Zmd�d�� Znd�d�� Zod�d�� Zpd�d�� Zqd�d�� Zrd�d�� Zsd�d�� Ztd�d�� Zud�d�� Zvd�d�� Zwd�d�� Zxd�d�� Zyd�d�� Zzd�d�� Z{d�d�� Z|d�d�� Z}d�d�� Z~d�d�� Zd�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�dÄ Z�d�dń Z�d�dDŽ Z�d�dɄ Z�d�d˄ Z�d�d̈́ Z�d�dτ Z�d�dф Z�d�dӄ Z�d�dՄ Z�d�dׄ Z�d�dل Z�d�dۄ Z�d�d݄ Z�d�d߄ Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d�� Z�d�d�� Z�d�d�� Z�dS )�al Header value parser implementing various email-related RFC parsing rules.
The parsing methods defined in this module implement various email related
parsing rules. Principal among them is RFC 5322, which is the followon
to RFC 2822 and primarily a clarification of the former. It also implements
RFC 2047 encoded word decoding.
RFC 5322 goes to considerable trouble to maintain backward compatibility with
RFC 822 in the parse phase, while cleaning up the structure on the generation
phase. This parser supports correct RFC 5322 generation by tagging white space
as folding white space only when folding is allowed in the non-obsolete rule
sets. Actually, the parser is even more generous when accepting input than RFC
5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
Where possible deviations from the standard are annotated on the 'defects'
attribute of tokens that deviate.
The general structure of the parser follows RFC 5322, and uses its terminology
where there is a direct correspondence. Where the implementation requires a
somewhat different structure than that used by the formal grammar, new terms
that mimic the closest existing terms are used. Thus, it really helps to have
a copy of RFC 5322 handy when studying this code.
Input to the parser is a string that has already been unfolded according to
RFC 5322 rules. According to the RFC this unfolding is the very first step, and
this parser leaves the unfolding step to a higher level message parser, which
will have already detected the line breaks that need unfolding while
determining the beginning and end of each header.
The output of the parser is a TokenList object, which is a list subclass. A
TokenList is a recursive data structure. The terminal nodes of the structure
are Terminal objects, which are subclasses of str. These do not correspond
directly to terminal objects in the formal grammar, but are instead more
practical higher level combinations of true terminals.
All TokenList and Terminal objects have a 'value' attribute, which produces the
semantically meaningful value of that part of the parse subtree. The value of
all whitespace tokens (no matter how many sub-tokens they may contain) is a
single space, as per the RFC rules. This includes 'CFWS', which is herein
included in the general class of whitespace tokens. There is one exception to
the rule that whitespace tokens are collapsed into single spaces in values: in
the value of a 'bare-quoted-string' (a quoted-string with no leading or
trailing whitespace), any whitespace that appeared between the quotation marks
is preserved in the returned value. Note that in all Terminal strings quoted
pairs are turned into their unquoted values.
All TokenList and Terminal objects also have a string value, which attempts to
be a "canonical" representation of the RFC-compliant form of the substring that
produced the parsed subtree, including minimal use of quoted pair quoting.
Whitespace runs are not collapsed.
Comment tokens also have a 'content' attribute providing the string found
between the parens (including any nested comments) with whitespace preserved.
All TokenList and Terminal objects have a 'defects' attribute which is a
possibly empty list all of the defects found while creating the token. Defects
may appear on any token in the tree, and a composite list of all defects in the
subtree is available through the 'all_defects' attribute of any node. (For
Terminal notes x.defects == x.all_defects.)
Each object in a parse tree is called a 'token', and each has a 'token_type'
attribute that gives the name from the RFC 5322 grammar that it represents.
Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
may be produced: 'ptext'. A 'ptext' is a string of printable ascii characters.
It is returned in place of lists of (ctext/quoted-pair) and
(qtext/quoted-pair).
XXX: provide complete list of token types.
� N)� hexdigits)�
itemgetter)�_encoded_words)�errors)�utilsz �(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%�
�
c C s dt | ��dd��dd� d S )N�"�\�\\z\")�str�replace��value� r �A/opt/alt/python310/lib64/python3.10/email/_header_value_parser.py�quote_stringb s r z�
=\? # literal =?
[^?]* # charset
\? # literal ?
[qQbB] # literal 'q' or 'b', case insensitive
\? # literal ?
.*? # encoded word
\?= # literal ?=
c s� e Zd ZdZdZdZ� fdd�Zdd� Z� fdd�Ze d d
� �Z
e dd� �Zd
d� Ze dd� �Z
e dd� �Zdd� Zddd�Zddd�Zddd�Z� ZS )� TokenListNTc s t � j|i |�� g | _d S �N)�super�__init__�defects)�self�args�kw�� __class__r r r { s
zTokenList.__init__c C � d� dd� | D ��S )N� c s � � | ]}t |�V qd S r �r ��.0�xr r r � <genexpr>� � � z$TokenList.__str__.<locals>.<genexpr>��join�r r r r �__str__ � zTokenList.__str__c � d� | jjt� �� �S �Nz{}({})��formatr �__name__r �__repr__r+ r r r r3 � s
�zTokenList.__repr__c C r )Nr! c s s � | ] }|j r|j V qd S r r r$ r r r r'