File: //lib64/python3.9/email/__pycache__/header.cpython-39.opt-2.pyc
a
    �DOg&^  �                   @   s�   g d �Z ddlZddlZddlZddlZddlmZ ddlmZ	 e	j
Z
dZdZdZ
dZd	Zd
ZdZe
d�Ze
d
�Ze�dejejB �Ze�d�Ze�d�ZejjZdd� Zddd�ZG dd� d�ZG dd� d�ZG dd� de �Z!dS ))�Header�
decode_header�make_header�    N)�HeaderParseError)�charset�
� �    z        � �N   z 	�us-asciizutf-8ai  
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qQbB])  # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:c              	   C   s�  t | d�rdd� | jD �S t�| �s.| d fgS g }| �� D ]�}t�|�}d}|r:|�d�}|rj|�� }d}|r~|�|d d f� |rL|�d��	� }|�d��	� }|�d�}|�|||f� qLq:g }	t
|�D ]J\}
}|
dkr�|d r�||
d  d r�||
d  d �� r�|	�|
d � q�t|	�D ]}||= �qg }
|D ]�\}}}|d u �rV|
�||f� n�|d	k�r|t
j�|�}|
�||f� n||d
k�r�t|�d }|�r�|dd d| � 7 }zt
j�|�}W n tj�y�   td
��Y n0 |
�||f� ntd| ���q2g }d  }}|
D ]v\}}t|t��r*t|d�}|d u �r>|}|}nB||k�r`|�||f� |}|}n |d u �rx|t| 7 }n||7 }�q|�||f� |S )N�_chunksc                 S   s(   g | ] \}}t �|t|��t|�f�qS � )�_charsetZ_encode�str)�.0�stringr   r   r   �$/usr/lib64/python3.9/email/header.py�
<listcomp>M   s   �z!decode_header.<locals>.<listcomp>Tr   F�   �   �q�b�   z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
   �ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr   �AssertionError�
isinstancer   �bytes�BSPACE)�header�words�line�parts�firstZ	unencodedr   �encoding�encodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetr   r   r   r   =   s|    
�
4
r   c                 C   sF   t |||d�}| D ].\}}|d ur4t|t�s4t|�}|�||� q|S )N)�
maxlinelen�header_name�continuation_ws)r   r-   �Charsetr!   )Zdecoded_seqr;   r<