teythoon/afew — Issue #27: [FolderNameFilter] Non-ASCII message headers cause crash
Author: herrsimon
Created: 2012-02-09 14:43:48+00:00
State: open

Hi,

When processing the FolderNameFilter, afew crashes with the error

Traceback (most recent call last):
File "/usr/bin/afew", line 169, in
main(options, query_string)
File "/usr/lib/python2.7/site-packages/afew/main.py", line 33, in main
filter_.run(query_string)
File "/usr/lib/python2.7/site-packages/afew/Filter.py", line 60, in run
self.handle_message(message)
File "/usr/lib/python2.7/site-packages/afew/filters/FolderNameFilter.py", line 44, in handle_message
folders, message.get_header('subject').encode('utf8')))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

if there are strange Characters in the subject (in my case, French accents and German umlauts in a mail sent over an MS Exchange server). After commenting out lines 44/55 in FolderNameFilter.py, i.e.

logging.debug('found folders {0} for message \'{1}\''.format(
folders, message.get_header('subject').encode('utf8')))

everything works fine again, so I guess it's some encoding problem. Maybe the log-message should be transformed into ASCII before logging. Unfortunately I'm don't know enough Python to fix this myself

Best,

Simon