Skip to content

Commit 978c8d1

Browse files
v0.50.0
1 parent cc21397 commit 978c8d1

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**v0.50.0**
2-
* [[TeamMsgExtractor #432](https://github.com/TeamMsgExtractor/msg-extractor/issues/432)] Adjust html header code to replace non-ascii characters with escaped versions.
2+
* [[TeamMsgExtractor #432](https://github.com/TeamMsgExtractor/msg-extractor/issues/432)] Adjust html header code to replace non-ascii characters with escaped versions. Also adujusted plain text to html conversion to ensure non-ascii character from the body are encoded to escpaed values to be safe.
3+
* Made some corrections to `NullDate`.
34

45
**v0.49.0**
56
* [[TeamMsgExtractor #427](https://github.com/TeamMsgExtractor/msg-extractor/issues/427)] Adjusted code for converting time stamps to create null dates for any time stamp beyond a certain point. The point was determined to be close to the existing null dates.

extract_msg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2828

2929
__author__ = 'Destiny Peterson & Matthew Walker'
30-
__date__ = '2024-10-02'
30+
__date__ = '2024-10-07'
3131
__version__ = '0.50.0'
3232

3333
__all__ = [

extract_msg/msg_classes/message_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,14 +1163,14 @@ def htmlBody(self) -> Optional[bytes]:
11631163
pass
11641164
elif self.rtfBody:
11651165
logger.info('HTML body was not found, attempting to generate from RTF.')
1166-
htmlBody = self.deencapsulateBody(self.rtfBody, DeencapType.HTML)
1166+
htmlBody = cast(bytes, self.deencapsulateBody(self.rtfBody, DeencapType.HTML))
11671167
# This is it's own if statement so we can ensure it will generate
11681168
# even if there is an rtfBody, in the event it doesn't have HTML.
11691169
if not htmlBody and self.body:
11701170
# Convert the plain text body to html.
11711171
logger.info('HTML body was not found, attempting to generate from plain text body.')
11721172
correctedBody = html.escape(self.body).replace('\r', '').replace('\n', '<br />')
1173-
htmlBody = f'<html><body>{correctedBody}</body></head>'.encode('utf-8')
1173+
htmlBody = f'<html><body>{correctedBody}</body></head>'.encode('ascii', 'xmlreplace')
11741174

11751175
if not htmlBody:
11761176
logger.info('HTML body could not be found nor generated.')
@@ -1213,7 +1213,7 @@ def htmlInjectableHeader(self) -> str:
12131213
prefix = '<div id="injectedHeader"><div><p class="MsoNormal">'
12141214
suffix = '<o:p></o:p></p></div></div>'
12151215
joinStr = '<br/>'
1216-
formatter = (lambda name, value: f'<b>{name}:</b>&nbsp;{inputToString(htmlSanitize(value), self.stringEncoding).encode("ascii", "xmlcharrefreplace").decode()}')
1216+
formatter = (lambda name, value: f'<b>{name}:</b>&nbsp;{inputToString(htmlSanitize(value), self.stringEncoding).encode('ascii', 'xmlcharrefreplace').decode()}')
12171217

12181218
return self.getInjectableHeader(prefix, joinStr, suffix, formatter)
12191219

extract_msg/null_date.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class NullDate(datetime.datetime):
2626
def __eq__(self, other) -> bool:
2727
if isinstance(other, NullDate):
2828
return True
29-
return super.__eq__(self, other)
29+
return super().__eq__(other)
3030

3131
def __ne__(self, other) -> bool:
3232
if isinstance(other, NullDate):
3333
return False
34-
return super.__eq__(self, other)
34+
return super().__eq__(other)

0 commit comments

Comments
 (0)