Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix htmlbody encoding for hebrew text #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/examples/iso-8859-8-i.tnef
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/test_tnef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tnefparse/mapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down