Kaydet (Commit) 15d37394 authored tarafından Barry Warsaw's avatar Barry Warsaw

make_header(): Watch out for charset is None, which decode_header()

will return as the charset if implicit us-ascii is used.
üst 2d5389c0
...@@ -55,7 +55,6 @@ def decode_header(header): ...@@ -55,7 +55,6 @@ def decode_header(header):
header = str(header) header = str(header)
if not ecre.search(header): if not ecre.search(header):
return [(header, None)] return [(header, None)]
decoded = [] decoded = []
dec = '' dec = ''
for line in header.splitlines(): for line in header.splitlines():
...@@ -63,7 +62,6 @@ def decode_header(header): ...@@ -63,7 +62,6 @@ def decode_header(header):
if not ecre.search(line): if not ecre.search(line):
decoded.append((line, None)) decoded.append((line, None))
continue continue
parts = ecre.split(line) parts = ecre.split(line)
while parts: while parts:
unenc = parts.pop(0).strip() unenc = parts.pop(0).strip()
...@@ -108,7 +106,8 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None, ...@@ -108,7 +106,8 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None,
h = Header(maxlinelen=maxlinelen, header_name=header_name, h = Header(maxlinelen=maxlinelen, header_name=header_name,
continuation_ws=continuation_ws) continuation_ws=continuation_ws)
for s, charset in decoded_seq: for s, charset in decoded_seq:
if not isinstance(charset, Charset): # None means us-ascii but we can simply pass it on to h.append()
if charset is not None and not isinstance(charset, Charset):
charset = Charset(charset) charset = Charset(charset)
h.append(s, charset) h.append(s, charset)
return h return h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment