diff --git a/tests/examples/iso-8859-8-i.tnef b/tests/examples/iso-8859-8-i.tnef new file mode 100644 index 0000000..bbd141c Binary files /dev/null and b/tests/examples/iso-8859-8-i.tnef differ diff --git a/tests/test_tnef.py b/tests/test_tnef.py index a29de7a..cfe1fc6 100644 --- a/tests/test_tnef.py +++ b/tests/test_tnef.py @@ -30,3 +30,10 @@ def test_bad_signature(): with pytest.raises(ValueError, match=r"Wrong TNEF signature: 0x\w+"): TNEF(tnef_data) + + +def test_tnef_htmlbody_hebrew_text(): + tnef_data = (HERE / "examples" / "iso-8859-8-i.tnef").read_bytes() + t = TNEF(tnef_data) + unicode_slice = t.htmlbody[1795:1799] + assert unicode_slice == u'\u05d5\u05d5\u05d0\u05dc', "Unexpected val in htmlbody" diff --git a/tnefparse/mapi.py b/tnefparse/mapi.py index 8d54e31..af37d78 100644 --- a/tnefparse/mapi.py +++ b/tnefparse/mapi.py @@ -151,7 +151,7 @@ def parse_property(data, offset, attr_name, attr_type, codepage, is_multi): item = data[offset: offset + length] if attr_type == SZMAPI_UNICODE_STRING: item = item.decode('utf-16') - elif attr_type == SZMAPI_STRING: + elif attr_type in (SZMAPI_STRING, SZMAPI_BINARY): item = item.decode(codepage) attr_data.append(item) offset += length