Sindbad~EG File Manager
3
�uGh�_ � @ sF d Z ddlmZ ddlmZ ddlmZ ddlmZmZmZm Z m
Z
dddgZdd lZdd l
Z
dd
lmZ ddlmZ ddlmZ dd ljjjZdd
lmZmZ ejZdZdZdZd!ZdZ dZ!dZ"ed�Z#ed�Z$ej%dej&ej'B ej(B �Z)ej%d�Z*ej%d�Z+dd� Z,d"dd�Z-G dd� de.�Z/G dd� de.�Z0G dd � d e1�Z2d S )#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�
� � � � �N z zus-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 tj| �s.| dfgS g }x�| j� D ]�}tj|�}d}xp|r�|jd�}|rn|j� }d}|r�|j|ddf� |rP|jd�j � }|jd�j � }|jd�}|j|||f� qPW q<W ddl
} g }
xVt|�D ]J\}}|dkr�|d r�||d d r�||d d j� r�|
j|d � q�W xt
|
�D ]}
||
= �q2W g }x�|D ]�\}}}|dk�rp|j||f� n�|d
k�r�t|�}|j||f� n||dk�rt|�d }|�r�|d
dd| � 7 }ytj|�}W n tjk
�r� td��Y nX |j||f� ntd| ���qLW g }d }}x~|D ]v\}}t|t��rDt|d�}|dk�rX|}|}nB||k�rz|j||f� |}|}n |dk�r�|t| 7 }n||7 }�q&W |j||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 j|t|��t|�f�qS � )�_charset�_encoder )�.0�string�charsetr r �D/root/tmp/pip-build-gzoz1_uw/future/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 >