patchew-project / patchew

A patch email tracking and testing system
MIT License
73 stars 24 forks source link

MboxMessage should operate on bytes #78

Open bonzini opened 6 years ago

bonzini commented 6 years ago

Currently whenever an MboxMessage is created, we decode the 8-bit input stream as UTF-8. For example:

class MessagePlainTextParser(BaseParser):
    media_type = 'message/rfc822'
    def parse(self, stream, media_type=None, parser_context=None):
        data = stream.read().decode("utf-8")
        return MboxMessage(data).get_json()

However, the encoding is specified in the email headers, which are always 7-bit. So MboxMessage should take a bytes object, not a string. The same issue is present in both the legacy and the REST APIs