diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-05-27 13:26:11 +0200 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-06-16 21:17:50 +0100 |
commit | fd76cd46e63f5d75b028d738d522a56b69cba601 (patch) | |
tree | 576659adc66baaea01aa1c1a62b94cfba105bb83 /alot/db/utils.py | |
parent | 919bba8d8e7368ffbf0710ebf9b4a31f2a7e4040 (diff) |
Normalize Content-Type parameters
RFC 2045 specifies that parameter names are case-insensitive, so
normalize them by converting them to their lower case version.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Diffstat (limited to 'alot/db/utils.py')
-rw-r--r-- | alot/db/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py index 9449f989..6861b39e 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -91,7 +91,11 @@ def message_from_file(handle): malformed = 'expected Content-Type: {0}, got: {1}'.format( want, ct) - p = {k:v for k, v in m.get_params()} + # Get Content-Type parameters as dict. RFC 2045 specifies that + # parameter names are case-insensitive, so we normalize them + # here. + p = {k.lower():v for k, v in m.get_params()} + if p.get('protocol', 'nothing') != want: malformed = 'expected protocol={0}, got: {1}'.format( want, p.get('protocol', 'nothing')) |