관리-도구
편집 파일: _header_value_parser.cpython-38.opt-1.pyc
U e5dϡ � @ 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� Zdd� Ze�dejejB �ZG dd� de�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�Z/G d5d6� d6e�Z0G d7d8� d8e�Z1G d9d:� d:e�Z2G d;d<� d<e�Z3G d=d>� d>e�Z4G d?d@� d@e�Z5G dAdB� dBe�Z6G dCdD� dDe�Z7G dEdF� dFe�Z8G dGdH� dHe�Z9G 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?�Z@G dWdX� dXe�ZAG dYdZ� dZe�ZBG d[d\� d\e�ZCG d]d^� d^e�ZDG d_d`� d`e�ZEG dadb� dbeE�ZFG dcdd� ddeE�ZGG dedf� dfe�ZHG dgdh� dhe�ZIG didj� dje�ZJG dkdl� dleJ�ZKG dmdn� dneK�ZLG dodp� dpe�ZMG dqdr� dreN�ZOG dsdt� dteO�ZPG dudv� dveO�ZQG dwdx� dxeP�ZRG dydz� dzejS�ZTeQdd{�ZUeQd|d}�ZVeQd~d�ZWe�d��Xd��Ye���jZZ[e�d��Xe�\d��Ye����j]Z^e�d��j_Z`e�d��Xe�\d��Ye����j]Zae�d��Xe�\d��Ye����j]Zbe�d��Xe�\d��Ye����j]Zcd�d�� Zdd�d�� 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�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�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 �2/usr/lib64/python3.8/email/_header_value_parser.py�quote_string` 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||� g | _d S �N)�super�__init__�defects)�self�args�kw�� __class__r r r y s zTokenList.__init__c C s d� dd� | D ��S )N� c s s | ]}t |�V qd S r �r ��.0�xr r r � <genexpr>~ s z$TokenList.__str__.<locals>.<genexpr>��join�r r r r �__str__} s zTokenList.__str__c s d� | jjt� �� �S �Nz{}({})��formatr �__name__r �__repr__r&