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

Support HTML bodies #30

Open
wants to merge 1 commit into
base: primary
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion outlookmsgfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def load_message_stream(entry, is_top_level, doc):
msg.set_content(body, maintype="text", subtype="plain", cte='8bit')
has_body = True

# Add a html body if available
if not has_body and 'HTML_BODY' in props:
body = props['HTML_BODY']
msg.set_content(body, maintype="text", subtype="plain", cte='8bit')
has_body = True

# Add a HTML body from the RTF_COMPRESSED field.
if 'RTF_COMPRESSED' in props:
# Decompress the value to Rich Text Format.
Expand Down Expand Up @@ -402,7 +408,11 @@ class UNICODE(VariableLengthValueLoader):
@staticmethod
def load(value, **kwargs):
# value is a bytestring encoded in UTF-16.
return value.decode("utf16")
decoded = value.decode("utf16")
# do c-style strings get encoded as utf16?
# is there an off-by-one error in the variable length math?
decoded = decoded.removesuffix('\x00')
Comment on lines -405 to +414
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be curious to know more about what might be going on here.

Earlier we have a value_length field that is ignored because we use the whole embedded stream. Maybe it can't be ignored.

return decoded

# TODO: The other variable-length tag types are "CLSID", "OBJECT".

Expand Down Expand Up @@ -592,6 +602,7 @@ def load(entry, doc, **kwargs):
0x1010: ('RTF_SYNC_PREFIX_COUNT', 'I4'),
0x1011: ('RTF_SYNC_TRAILING_COUNT', 'I4'),
0x1012: ('ORIGINALLY_INTENDED_RECIP_ENTRYID', 'BINARY'),
0x1013: ('HTML_BODY', 'BINARY'),
0x0C00: ('CONTENT_INTEGRITY_CHECK', 'BINARY'),
0x0C01: ('EXPLICIT_CONVERSION', 'I4'),
0x0C02: ('IPM_RETURN_REQUESTED', 'BOOLEAN'),
Expand Down