summaryrefslogtreecommitdiffstats
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xatomail.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/atomail.py b/atomail.py
index ee222c2..c663c05 100755
--- a/atomail.py
+++ b/atomail.py
@@ -59,6 +59,7 @@ PROGRAM_USAGESTRING = "usage: %prog [options] file"
59PROGRAM_VERSIONSTRING = PROGRAM_NAME + ' ' + __version__ + '\nWritten by ' + __author__ + '\n' + 'For more information, please visit ' + PROGRAM_URI 59PROGRAM_VERSIONSTRING = PROGRAM_NAME + ' ' + __version__ + '\nWritten by ' + __author__ + '\n' + 'For more information, please visit ' + PROGRAM_URI
60 60
61ATOM_NS = 'http://www.w3.org/2005/Atom' 61ATOM_NS = 'http://www.w3.org/2005/Atom'
62DEFAULT_ENCODING = "iso8859-1" # This will be used to decode headers if no encoding is specified. Should probably be smarter about this. See usage for more info
62 63
63################################################################################ 64################################################################################
64# Auxiliary functions and classes 65# Auxiliary functions and classes
@@ -137,6 +138,11 @@ def entry_date(entry) :
137def decode_header(header, default) : 138def decode_header(header, default) :
138 decoded_header = "" 139 decoded_header = ""
139 for (result, encoding) in email.header.decode_header(header if header else default) : 140 for (result, encoding) in email.header.decode_header(header if header else default) :
141 # Some mails don't have an encoding in the header, yet they do encode the
142 # header. We should do trial and error here, but for now assume it's
143 # Iso8859-1.
144 if not encoding :
145 encoding = DEFAULT_ENCODING
140 decoded_header += result.decode(encoding, "ignore") if encoding else result 146 decoded_header += result.decode(encoding, "ignore") if encoding else result
141 return decoded_header 147 return decoded_header
142 148