Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions flanker/mime/message/headers/parametrized.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def concatenate(parts):
if is_old_style(part):
# old-style parameters do not support any continuations
return encodedword.mime_to_unicode(get_value(part))

return ''.join(decode_new_style(p) for p in partition(parts))
elif is_single_part(part):
return decode_new_style(part)
else:
return ''.join(decode_new_style(p) for p in partition(parts))


def match_parameter(rest):
Expand Down Expand Up @@ -234,6 +236,10 @@ def is_encoded(part):
return part[1][2] == '*'


def is_single_part(part):
return part[1][1] is None


def get_key(parameter):
if is_old_style(parameter):
return parameter[1].lower()
Expand Down
7 changes: 6 additions & 1 deletion tests/mime/message/headers/parametrized_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@ def content_types_test():
eq_(('multipart/mixed', {'boundary': 'Alternative_Boundary_8dJn:mu0M2Yt5KaFZ8AdJn:mu0M2=Yt1KaFdA'}), parametrized.decode(''' multipart/mixed; \n\tboundary="Alternative_Boundary_8dJn:mu0M2Yt5KaFZ8AdJn:mu0M2=Yt1KaFdA"'''))
eq_(('multipart/mixed', {'boundary': '16819560-2078917053-688350843:#11603'}), parametrized.decode('''MULTIPART/MIXED;BOUNDARY="16819560-2078917053-688350843:#11603"'''))


def content_type_param_with_spaces_test():
eq_(('multipart/alternative',{'boundary':'nextPart'}), parametrized.decode("multipart/alternative; boundary = nextPart"))
eq_(('multipart/alternative', {'boundary': 'nextPart'}), parametrized.decode("multipart/alternative; boundary = nextPart"))


def content_type_same_param_name_encoded_unencoded_test():
eq_(('application/pdf', {'name': '30676_2015.pdf'}), parametrized.decode("application/pdf; name=30676_2015.pdf;name*=iso-8859-1''%33%30%36%37%36%5F%32%30%31%35%2E%70%64%66"))