Ś˙f^ c @ s^ d Z d d d g Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z
e
j Z d Z d Z
d
Z d Z d Z d
Z d Z e d Z e d Z e j d e j e j Be j B Z e j d Z e j d Z e j j Z d d Z d d d d d Z Gd d d Z! Gd d d Z" Gd d d e# Z$ d S( u+ Header encoding and decoding functionality.u Headeru
decode_headeru make_headeri N( u HeaderParseError( u charsetu
u s i u iN u u us-asciiu utf-8ui
=\? # literal =?
(?P[^?]*?) # non-greedy up to the next ? is the charset
\? # literal ?
(?P[qb]) # either a "q" or a "b", case insensitive
\? # literal ?
(?P.*?) # non-greedy up to the next ?= is the encoded string
\?= # literal ?=
u [\041-\176]+:$u
\n[^ \t]+:c C s˘ t | d r# d d | j D St j | s? | d f g Sg } x× | j D]É } t j | } d } xŤ | r| j d } | r | j } d } n | rż | j | d d f n | rp | j d j } | j d j } | j d } | j | | | f qp qp WqR Wd d l
} g }
xn t | D]` \ } } | d k r>| d r>| | d d r>| | d d j r>|
j | d q>q>Wx t |
D]
}
| |
=qŻWg } x
| D]\ } } } | d k rţ| j | | f qÍ| d k r2t j j | } | j | | f qÍ| d k rżt | d
} | ro| d d d
|
7} n y t j j | } Wn! t j k
r¨t d YqĎX| j | | f qÍt d
| qÍWg } d } } xĽ | D] \ } } t | t rt | d } n | d k r2| } | } qę| | k r`| j | | f | } | } qę| d k r}| t | 7} qę| | 7} qęW| j | | f | S( u; 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).
u _chunksc S s: g | ]0 \ } } t j | t | t | f q S( ( u _charsetu _encodeu str( u .0u stringu charset( ( u1 /opt/alt/python33/lib64/python3.3/email/header.pyu
M s u! decode_header..i Ni i u qu bi u ===u Base64 decoding erroru Unexpected encoding: u raw-unicode-escapeTF( u hasattru _chunksu ecreu searchu Noneu
splitlinesu splitu Trueu popu lstripu Falseu appendu loweru sysu enumerateu isspaceu reversedu emailu
quoprimimeu
header_decodeu lenu
base64mimeu decodeu binasciiu Erroru HeaderParseErroru AssertionErroru
isinstanceu stru bytesu BSPACE( u headeru wordsu lineu partsu firstu unencodedu charsetu encodingu encodedu sysu droplistu nu wu du
decoded_wordsu encoded_stringu wordu paderru collapsedu last_wordu last_charset( ( u1 /opt/alt/python33/lib64/python3.3/email/header.pyu
decode_header= s|
!@
c C sq t d | d | d | } xO | D]G \ } } | d k rY t | t rY t | } n | j | | q" W| S( uź Create a Header from a sequence of pairs as returned by decode_header()
decode_header() takes a header value string and returns a sequence of
pairs of the format (decoded_string, charset) where charset is the string
name of the character set.
This function takes one of those sequence of pairs and returns a Header
instance. Optional maxlinelen, header_name, and continuation_ws are as in
the Header constructor.
u
maxlinelenu header_nameu continuation_wsN( u Headeru Noneu
isinstanceu Charsetu append( u decoded_sequ
maxlinelenu header_nameu continuation_wsu hu su charset( ( u1 /opt/alt/python33/lib64/python3.3/email/header.pyu make_header s c B s | Ee Z d Z d d d d d d d d Z d d Z d d Z d d
Z d d d d Z d
d Z d d d d d Z
d d Z d S( u Headeru u strictc C s˝ | d k r t } n t | t s3 t | } n | | _ | | _ g | _ | d k rp | j | | | n | d k r
t } n | | _ | d k rŚ d | _
n t | d | _
d S( uD Create a MIME-compliant header that can contain many character sets.
Optional s is the initial header value. If None, the initial header
value is not set. You can later append to the header with .append()
method calls. s may be a byte string or a Unicode string, but see the
.append() documentation for semantics.
Optional charset serves two purposes: it has the same meaning as the
charset argument to the .append() method. It also sets the default
character set for all subsequent .append() calls that omit the charset
argument. If charset is not provided in the constructor, the us-ascii
charset is used both as s's initial charset and as the default for
subsequent .append() calls.
The maximum line length can be specified explicitly via maxlinelen. For
splitting the first line to a shorter value (to account for the field
header which isn't included in s, e.g. `Subject') pass in the name of
the field in header_name. The default maxlinelen is 78 as recommended
by RFC 2822.
continuation_ws must be RFC 2822 compliant folding whitespace (usually
either a space or a hard tab) which will be prepended to continuation
lines.
errors is passed through to the .append() call.
i i N( u Noneu USASCIIu
isinstanceu Charsetu _charsetu _continuation_wsu _chunksu appendu
MAXLINELENu _maxlinelenu
_headerlenu len( u selfu su charsetu
maxlinelenu header_nameu continuation_wsu errors( ( u1 /opt/alt/python33/lib64/python3.3/email/header.pyu __init__ľ s u Header.__init__c C s( | j g } d } d } xü | j D]ń \ } } | } | t j k rn | j d d } | j d d } n | rë | o | j | d } | d k rĹ | d k rč | rč | j t d } qč që | d
k rë | rë | j t që n | o| j | d } | } | j | q&