Lines Matching refs: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 decoded parts of the header. Charset is None for non-encoded parts of the
68 header, otherwise a lower-case string containing the name of the character
74 # If no encoding, just return the header
75 header = str(header)
76 if not ecre.search(header):
77 return [(header, None)]
80 for line in header.splitlines():
126 """Create a Header from a sequence of pairs as returned by decode_header()
128 decode_header() takes a header value string and returns a sequence of
132 This function takes one of those sequence of pairs and returns a Header
134 the Header constructor.
136 h = Header(maxlinelen=maxlinelen, header_name=header_name,
148 class Header:
152 """Create a MIME-compliant header that can contain many character sets.
154 Optional s is the initial header value. If None, the initial header
155 value is not set. You can later append to the header with .append()
168 header which isn't included in s, e.g. `Subject') pass in the name of
191 # We don't know anything about the field header so the first line
196 # header. Also subtract off 2 extra for the colon and space.
230 # other may be a Header or a string. Both are fine so coerce
238 """Append a string to the MIME header.
250 the string. In this case, when producing an RFC 2822 compliant header
293 # Split up a header safely for use with encode_chunks.
304 # be to not split the header at all, but that means they could go out
344 # MIME-encode a header with many different charsets and/or encodings.
347 # string suitable for use in a header field. Each pair may have
348 # different charsets and/or encodings, and the resulting header will
362 for header, charset in newchunks:
363 if not header:
366 s = header
368 s = charset.header_encode(header)
379 """Encode a message header into an RFC-compliant format.
382 an email header
383 email clients, and as header strings can only contain a subset of
385 Base64 or quoted-printable) header strings. In addition, there is a
386 75-character length limit on any given encoded header field, so
394 conversion, this function will return the header untouched.
416 raise HeaderParseError("header value appears to contain "
417 "an embedded header: {!r}".format(value))
463 # first line and the field name is present in the header string.