File: //usr/local/lib/python3.9/site-packages/future/backports/email/__pycache__/header.cpython-39.pyc
a
q�dg�_ � @ sN d Z ddlmZ ddlmZ ddlmZ ddlmZmZmZm Z m
Z
g d�ZddlZddl
Z
ddlmZ dd lmZ dd
lmZ ddlm m mZ ddlmZmZ ejZdZd
ZdZdZdZ dZ!dZ"ed�Z#ed�Z$e�%dej&ej'B ej(B �Z)e�%d�Z*e�%d�Z+dd� Z,d"dd�Z-G dd� de.�Z/G dd� de.�Z0G d d!� d!e1�Z2dS )#z+Header encoding and decoding functionality.� )�unicode_literals)�division)�absolute_import)�bytes�range�str�super�zip)�Header�
decode_header�make_headerN)�email)�
base64mime)�HeaderParseError)�_max_append�
header_decode�
� � z � �N z �us-asciizutf-8ai
=\? # literal =?
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
\? # literal ?
(?P<encoding>[qb]) # 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.| dfgS g }| �� D ]�}t�|�}d}|r:|�d�}|rj|�� }d}|r~|�|ddf� |rL|�d�� � }|�d�� � }|�d�}|�|||f� qLq:ddl
} g }
t|�D ]J\}}|dkr�|d r�||d d r�||d d �� r�|
�|d � q�t
|
�D ]}
||
= �q$g }|D ]�\}}}|du �r^|�||f� n�|d
k�r�t|�}|�||f� nz|dk�r�t|�d }|�r�|d
dd| � 7 }zt�|�}W n tj�y� td��Y n0 |�||f� ntd| ���q:g }d }}|D ]v\}}t|t��r,t|d�}|du �r@|}|}nB||k�rb|�||f� |}|}n |du �rz|t| 7 }n||7 }�q|�||f� |S )a; Decode a message header value without converting charset.
Returns a list of (string, charset) pairs containing each of the decoded
parts of the header. Charset is None for non-encoded parts of the header,
otherwise a lower-case string containing the name of the character set
specified in the encoded string.
header may be a string that may or may not contain RFC2047 encoded words,
or it may be a Header object.
An email.errors.HeaderParseError may be raised when certain decoding error
occurs (e.g. a base64 decoding exception).
�_chunksc S s( g | ] \}}t �|t|��t|�f�qS � )�_charset�_encoder )�.0�string�charsetr r �G/usr/local/lib/python3.9/site-packages/future/backports/email/header.py�
<listcomp>N s �z!decode_header.<locals>.<listcomp>NTr F� � �q�b� z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr �ecre�search�
splitlines�split�pop�lstrip�append�lower�sys� enumerate�isspace�reversedr �lenr �decode�binascii�Errorr �AssertionError�
isinstancer r �BSPACE)�header�words�line�parts�first� unencodedr �encoding�encodedr/ �droplist�n�w�d�
decoded_words�encoded_string�word�paderr� collapsed� last_word�last_charsetr r r r >