Skip to content
  • 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: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
    1c5522df