From fd76cd46e63f5d75b028d738d522a56b69cba601 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 27 May 2013 13:26:11 +0200 Subject: 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> --- alot/db/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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')) -- cgit v1.2.3