LXMessage.unpack: check if title and content are byte arrays or strings#26
LXMessage.unpack: check if title and content are byte arrays or strings#26leroycep wants to merge 1 commit intomarkqvist:masterfrom
LXMessage.unpack: check if title and content are byte arrays or strings#26Conversation
|
Content and titles should never be strings, but always binary data in UTF-8 encoding. To support any language and character set, LXMF only supports UTF-8 for parts that are intended for human readability. This should have been made more explicit, though, and I think the right way to go about this is to not accept messages where the byte arrays of As you can see in |
|
Quoting the msgpack spec:
It seems like msgpack defines the string type to mean a UTF-8 encoded byte array. That implies that the implementation should be switched to use only msgpack strings and not byte array, no? |
If a the
msgpacked portion of an LXMessage uses strings (fixstrtags0xa0to0xbf, and probablystr_8(0xd9),str_16(0xda), andstr_32(0xdb) as well) instead of byte arrays, LXMF will happily unpack them but then crash when trying to decode the string. For example:(Side note, is there a reason to LXMF uses byte arrays in the msgpack instead of strings? Like, does msgpack not specify UTF-8 as the string format or something?)
This PR changes
unpackto have logic similar toLXMessage.__init__, where it will always decode it into UTF-8 byte array based on the type.