File: //usr/lib/python3/dist-packages/future/backports/email/__pycache__/header.cpython-310.pyc
o
,�]�_ � @ sR 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�r
dd� | jD �S t�| �s| dfgS g }| �� D ]A}t�|�}d}|r^|�d�}|r5|�� }d}|r?|�|ddf� |r\|�d�� � }|�d�� � }|�d�}|�|||f� |s(qddl
} g }
t|�D ]%\}}|dkr�|d r�||d d r�||d d �� r�|
�|d � qit
|
�D ]}
||
= q�g }|D ]X\}}}|du r�|�||f� q�|d
kr�t|�}|�||f� q�|dkr�t|�d }|r�|d
dd| � 7 }zt�|�}W n tjy� td��w |�||f� q�td| ��g }d }}|D ]:\}}t|t��r
t|d�}|du �r|}|}q�||k�r(|�||f� |}|}q�|du �r4|t| 7 }q�||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 �?/usr/lib/python3/dist-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 >