|
|
|
| @@ -59,6 +59,7 @@ PROGRAM_USAGESTRING = "usage: %prog [options] file" |
| 59 | PROGRAM_VERSIONSTRING = PROGRAM_NAME + ' ' + __version__ + '\nWritten by ' + __author__ + '\n' + 'For more information, please visit ' + PROGRAM_URI |
59 | PROGRAM_VERSIONSTRING = PROGRAM_NAME + ' ' + __version__ + '\nWritten by ' + __author__ + '\n' + 'For more information, please visit ' + PROGRAM_URI |
| 60 | |
60 | |
| 61 | ATOM_NS = 'http://www.w3.org/2005/Atom' |
61 | ATOM_NS = 'http://www.w3.org/2005/Atom' |
| |
62 | DEFAULT_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) : |
| 137 | def decode_header(header, default) : |
138 | def 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 | |
|