• Arkadiusz Hiler's avatar
    parsemail: Handle malformed headers better · 1c5522df
    Arkadiusz Hiler authored
    Some servers have tendency to send non-RFC compliant headers which
    causes patchwork to hiccup. Their admins are reluctant to act on it and
    we cannot just force whole bunch of users to switch providers.
    
    Let's do our bit of the robustness principle and be more liberal about
    what we take.
    
    There are actually two solution in place, one for PY2 and one for PY3.
    
    PY2 is fine with reading the malformed file, but fails at header
    encoding, so we just need to catch the exception and discard the header.
    
    PY3 is a bit more complex. Since there were a lot of changes in how
    files and strings are handled, we have to read the mail explicitly as
    binary otherwise we get decode errors, hence the sys.stdin.buffer.
    
    The changes in the email module and the addition of
    message_from_binary_file() takes care of the issue for us.
    Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
    1c5522df
Name
Last commit
Last update
..
bin Loading commit data...
fixtures Loading commit data...
management Loading commit data...
migrations Loading commit data...
settings Loading commit data...
templates Loading commit data...
templatetags Loading commit data...
tests Loading commit data...
views Loading commit data...
__init__.py Loading commit data...
admin.py Loading commit data...
celery.py Loading commit data...
context_processors.py Loading commit data...
email.py Loading commit data...
fields.py Loading commit data...
filters.py Loading commit data...
forms.py Loading commit data...
lock.py Loading commit data...
middleware.py Loading commit data...
models.py Loading commit data...
paginator.py Loading commit data...
parser.py Loading commit data...
permissions.py Loading commit data...
serializers.py Loading commit data...
tasks.py Loading commit data...
threadlocalrequest.py Loading commit data...
urls.py Loading commit data...
utils.py Loading commit data...