Lines Matching defs:Header
5 """Header encoding and decoding functionality."""
8 'Header',
50 # Find a header embedded in a putative header value. Used to check for
51 # header injection attack.
63 def decode_header(header):
64 """Decode a message header value without converting charset.
67 parts of the header. Charset is None for non-encoded parts of the header,
71 header may be a string that may or may not contain RFC2047 encoded words,
72 or it may be a Header object.
77 # If it is a Header object, we can just return the encoded chunks.
78 if hasattr(header, '_chunks'):
80 for string, charset in header._chunks]
81 # If no encoding, just return the header with no charset.
82 if not ecre.search(header):
83 return [(header, None)]
88 for line in header.splitlines():
161 """Create a Header from a sequence of pairs as returned by decode_header()
163 decode_header() takes a header value string and returns a sequence of
167 This function takes one of those sequence of pairs and returns a Header
169 the Header constructor.
171 h = Header(maxlinelen=maxlinelen, header_name=header_name,
183 class Header:
187 """Create a MIME-compliant header that can contain many character sets.
189 Optional s is the initial header value. If None, the initial header
190 value is not set. You can later append to the header with .append()
203 header which isn't included in s, e.g. `Subject') pass in the name of
232 """Return the string value of the header."""
264 # other may be a Header or a string. Both are fine so coerce
265 # ourselves to a unicode (of the unencoded header value), swap the
270 """Append a string to the MIME header.
283 header using RFC 2047 rules, the string will be encoded using the
318 r"""Encode a message header into an RFC-compliant format.
321 an email header. Only certain character sets are readable in most
322 email clients, and as header strings can only contain a subset of
324 Base64 or quoted-printable) header strings. In addition, there is a
325 75-character length limit on any given encoded header field, so
331 will be shorter by the length of the header name plus ": " if a header
332 name was specified at Header construction time. The default value for
333 maxlinelen is determined at header construction time.
336 given extra weight by the splitting algorithm during normal header
393 raise HeaderParseError("header value appears to contain "
394 "an embedded header: {!r}".format(value))
449 # If the charset has no header encoding (i.e. it is an ASCII encoding)
450 # then we must split the header at the "highest level syntactic break"
492 # The RFC 2822 header folding algorithm is simple in principle but
533 # There will be a header, so leave it on a line by itself.
537 # after a header should always be a space.