From 43364114dd5608aeff06afa1c522ed5c66ea4103 Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Wed, 10 May 2023 10:22:33 -0700 Subject: [PATCH 1/8] Fix #362 --- CHANGELOG.md | 3 +++ README.rst | 4 ++-- extract_msg/__init__.py | 4 ++-- extract_msg/utils.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bace494..c68fed5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +**v0.41.1** +* [[TeamMsgExtractor #357](https://github.com/TeamMsgExtractor/msg-extractor/issues/362)] Fixed an issue with the removal of the `--dev` option missing one of the checks (I swear I actually tested it). + **v0.41.0** * [[TeamMsgExtractor #357](https://github.com/TeamMsgExtractor/msg-extractor/issues/357)] Fixed an issue where the properties stream being absent would raise an error message that was not clear. * [[TeamMsgExtractor #357](https://github.com/TeamMsgExtractor/msg-extractor/issues/357)] Added a way to suppress `StandardViolationError` for poorly created files. This may cause issues you might not expect since this exception is meant to stop the processing for a reason. diff --git a/README.rst b/README.rst index b8d3e91a..2a1fb8be 100644 --- a/README.rst +++ b/README.rst @@ -250,8 +250,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.0-blue.svg - :target: https://pypi.org/project/extract-msg/0.41.0/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.1-blue.svg + :target: https://pypi.org/project/extract-msg/0.41.1/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg :target: https://www.python.org/downloads/release/python-3816/ diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index 0642b841..c992c952 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -27,8 +27,8 @@ # along with this program. If not, see . __author__ = 'Destiny Peterson & Matthew Walker' -__date__ = '2023-05-09' -__version__ = '0.41.0' +__date__ = '2023-05-10' +__version__ = '0.41.1' __all__ = [ # Modules: diff --git a/extract_msg/utils.py b/extract_msg/utils.py index 2c9cf80e..1d919769 100644 --- a/extract_msg/utils.py +++ b/extract_msg/utils.py @@ -387,7 +387,7 @@ def getCommandArgs(args) -> argparse.Namespace: if options.outName and options.noFolders: raise IncompatibleOptionsError('--out-name is not compatible with --no-folders.') - if options.dev or options.fileLogging: + if options.fileLogging: options.verbose = options.verbose or 1 # Handle the wkOptions if they exist. From d75c868c3bc178a730e2d3758010561afbfba62a Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Wed, 10 May 2023 10:23:44 -0700 Subject: [PATCH 2/8] Fix bad link in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c68fed5d..99380f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ **v0.41.1** -* [[TeamMsgExtractor #357](https://github.com/TeamMsgExtractor/msg-extractor/issues/362)] Fixed an issue with the removal of the `--dev` option missing one of the checks (I swear I actually tested it). +* [[TeamMsgExtractor #362](https://github.com/TeamMsgExtractor/msg-extractor/issues/362)] Fixed an issue with the removal of the `--dev` option missing one of the checks (I swear I actually tested it). **v0.41.0** * [[TeamMsgExtractor #357](https://github.com/TeamMsgExtractor/msg-extractor/issues/357)] Fixed an issue where the properties stream being absent would raise an error message that was not clear. From 6a215fa65f1523b5b6ed8b11ed6f3bba058a3284 Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Wed, 24 May 2023 18:58:40 -0700 Subject: [PATCH 3/8] Version 0.41.2 --- CHANGELOG.md | 5 +++++ README.rst | 4 ++-- extract_msg/__init__.py | 4 ++-- extract_msg/enums.py | 31 ++++++++++++++++++++++++++----- extract_msg/message_base.py | 23 +++++++++++++++++++++-- 5 files changed, 56 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99380f5c..42f63a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +**v0.41.2** +* Updated annotations on `MessageBase.save`. +* Added new enum `BodyTypes`. +* Added property `MessageBase.detectedBodies` for detecting what bodies have been stored (not generated by the module) in the .msg file. + **v0.41.1** * [[TeamMsgExtractor #362](https://github.com/TeamMsgExtractor/msg-extractor/issues/362)] Fixed an issue with the removal of the `--dev` option missing one of the checks (I swear I actually tested it). diff --git a/README.rst b/README.rst index 2a1fb8be..a83f9b45 100644 --- a/README.rst +++ b/README.rst @@ -250,8 +250,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.1-blue.svg - :target: https://pypi.org/project/extract-msg/0.41.1/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.2-blue.svg + :target: https://pypi.org/project/extract-msg/0.41.2/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg :target: https://www.python.org/downloads/release/python-3816/ diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index c992c952..d99c9906 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -27,8 +27,8 @@ # along with this program. If not, see . __author__ = 'Destiny Peterson & Matthew Walker' -__date__ = '2023-05-10' -__version__ = '0.41.1' +__date__ = '2023-05-24' +__version__ = '0.41.2' __all__ = [ # Modules: diff --git a/extract_msg/enums.py b/extract_msg/enums.py index dbab2ddd..f5ace9b5 100644 --- a/extract_msg/enums.py +++ b/extract_msg/enums.py @@ -2,7 +2,7 @@ 'AddressBookType', 'AppointmentAuxilaryFlag', 'AppointmentColor', 'AppointmentStateFlag', 'AttachErrorBehavior', 'AttachmentType', 'BCImageAlignment', 'BCImageSource', 'BCLabelFormat', 'BCTemplateID', - 'BCTextFormat', 'BusyStatus', 'ClientIntentFlag', 'Color', + 'BCTextFormat', 'BodyTypes', 'BusyStatus', 'ClientIntentFlag', 'Color', 'ContactAddressIndex', 'ContactLinkState', 'DeencapType', 'DirectoryEntryType', 'DisplayType', 'ElectronicAddressProperties', 'EntryIDType', 'EntryIDTypeHex', 'ErrorCode', 'ErrorCodeType', 'Gender', @@ -264,6 +264,27 @@ class BCTextFormat(enum.Enum): +class BodyTypes(enum.IntFlag): + """ + Enum representing the types of bodies found in a message. This does not + include bodies generated from other sources, and so is a good detection + method for generated bodies (if you check a body and it is not null, but it + is not listed in the enum, then it was generated from another body). + + This is an IntFlag enum, so to check if a body was found use the & operator + with the body you are checking and ensuring the result isn't BodyTypes.None. + You can also convert the result to a bool. For example: + + >>> rtfFound = bool(msg.detectedBodies & BodyTypes.RTF) + """ + NONE = 0b000 + PLAIN = 0b001 + RTF = 0b010 + HTML = 0b100 + ALL = 0b111 + + + class BusyStatus(enum.Enum): """ The availability of a use for the event described by the object. @@ -467,7 +488,7 @@ def toRaw(self): class ErrorBehavior(enum.IntFlag): """ - The behavior to follow when handling an error in an MSG file and it's + The behavior to follow when handling an error in an MSG file and it's attachments. This is an int flag enum, so the options you want will be ORed with each other. @@ -1702,7 +1723,7 @@ def fromBits(cls, value : int) -> Set['TZFlag']: class _EnumDeprecator: """ - Special class for handling deprecated enums in a way that shouldn't break + Special class for handling deprecated enums in a way that shouldn't break existing code, including code for checking `is` on a member of the enum. """ def __init__(self, oldClassName : str, newClass : enum.Enum, nameConversion : dict = {}, valueConversion : dict = {}): @@ -1732,7 +1753,7 @@ def __getattr__(self, key): warnings.warn(self.__warnMessage, DeprecationWarning) return getattr(self.__new, self.__nameConv.get(key, key)) - + def __getitem__(self, name): # Warn about the deprecation import warnings @@ -1745,7 +1766,7 @@ def __getitem__(self, name): # Deprecated Enums AttachErrorBehavior = _EnumDeprecator( - 'AttachErrorBehavior', + 'AttachErrorBehavior', ErrorBehavior, { 'BROKEN': 'ATTACH_SUPPRESS_ALL', diff --git a/extract_msg/message_base.py b/extract_msg/message_base.py index 6c16e6ab..4dfbf785 100644 --- a/extract_msg/message_base.py +++ b/extract_msg/message_base.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + __all__ = [ 'MessageBase', ] @@ -6,6 +9,7 @@ import base64 import datetime import email.utils +import functools import html import json import logging @@ -26,7 +30,7 @@ from . import constants from ._rtf.create_doc import createDocument from ._rtf.inject_rtf import injectStartRTF -from .enums import DeencapType, RecipientType +from .enums import BodyTypes, DeencapType, RecipientType from .exceptions import ( BadHtmlError, DataNotFoundError, DeencapMalformedData, DeencapNotEncapsulated, IncompatibleOptionsError, WKError @@ -593,7 +597,7 @@ def replace(bodyMarker): logger.debug('Using _rtf module to inject RTF text header.') return createDocument(injectStartRTF(self.rtfBody, injectableHeader)) - def save(self, **kwargs): + def save(self, **kwargs) -> MessageBase: """ Saves the message body and attachments found in the message. @@ -1027,6 +1031,21 @@ def defaultFolderName(self) -> str: self._defaultFolderName = dirName return dirName + @functools.cached_property + def detectedBodies(self) -> BodyTypes: + """ + The types of bodies stored in the .msg file. + """ + bodies = BodyTypes.NONE + if self.sExists('__substg1.0_1000'): + bodies |= BodyTypes.PLAIN + if self.exists('__substg1.0_10090102'): + bodies |= BodyTypes.RTF + if self.exists('__substg1.0_10130102'): + bodies |= BodyTypes.HTML + + return bodies + @property def header(self): """ From cfc9682cd4e4536377b4783354c2bf167b60085a Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Sat, 10 Jun 2023 19:25:20 -0700 Subject: [PATCH 4/8] Fix for #365 (v0.41.3) --- CHANGELOG.md | 5 +++++ README.rst | 4 ++-- extract_msg/__init__.py | 4 ++-- extract_msg/message_base.py | 25 +++++++++++++++++-------- extract_msg/utils.py | 16 ++++++++++++++++ 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42f63a3e..00bb4278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +**v0.41.3** +* [[TeamMsgExtractor #365](https://github.com/TeamMsgExtractor/msg-extractor/issues/365)] Fixed an issue that would cause certain values retrieved from the header to not be decoded properly. It does this when retrieving the values, so nothing about the header has been changed. +* Added new property `MessageBase.headerText` which is the text content of the header stream. Adjusted other things to use this instead of trying to retrieve the stream directly in multiple places. +* Added typing to `MessageBase.header`. + **v0.41.2** * Updated annotations on `MessageBase.save`. * Added new enum `BodyTypes`. diff --git a/README.rst b/README.rst index a83f9b45..5516c8a7 100644 --- a/README.rst +++ b/README.rst @@ -250,8 +250,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.2-blue.svg - :target: https://pypi.org/project/extract-msg/0.41.2/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.3-blue.svg + :target: https://pypi.org/project/extract-msg/0.41.3/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg :target: https://www.python.org/downloads/release/python-3816/ diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index d99c9906..0021ce89 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -27,8 +27,8 @@ # along with this program. If not, see . __author__ = 'Destiny Peterson & Matthew Walker' -__date__ = '2023-05-24' -__version__ = '0.41.2' +__date__ = '2023-06-10' +__version__ = '0.41.3' __all__ = [ # Modules: diff --git a/extract_msg/message_base.py b/extract_msg/message_base.py index 4dfbf785..e9014bca 100644 --- a/extract_msg/message_base.py +++ b/extract_msg/message_base.py @@ -39,9 +39,9 @@ from .structures.report_tag import ReportTag from .recipient import Recipient from .utils import ( - addNumToDir, addNumToZipDir, createZipOpen, findWk, htmlSanitize, - inputToBytes, inputToString, isEncapsulatedRtf, prepareFilename, - rtfSanitizeHtml, rtfSanitizePlain, validateHtml + addNumToDir, addNumToZipDir, createZipOpen, decodeRfc2047, findWk, + htmlSanitize, inputToBytes, inputToString, isEncapsulatedRtf, + prepareFilename, rtfSanitizeHtml, rtfSanitizePlain, validateHtml ) from imapclient.imapclient import decode_utf7 @@ -135,6 +135,7 @@ def _genRecipient(self, recipientType, recipientInt : RecipientType) -> Optional if self.headerInit(): value = self.header[recipientType] if value: + value = decodeRfc2047(value) value = value.replace(',', self.__recipientSeparator) # If the header had a blank field or didn't have the field, generate @@ -792,7 +793,7 @@ def save(self, **kwargs) -> MessageBase: # If the user has requested the headers for this file, save it now. if kwargs.get('saveHeader', False): - headerText = self._getStringStream('__substg1.0_007D') + headerText = self.headerText if not headerText: headerText = constants.HEADER_FORMAT.format(subject = self.subject, **self.header) @@ -1047,7 +1048,7 @@ def detectedBodies(self) -> BodyTypes: return bodies @property - def header(self): + def header(self) -> email.message.Message: """ Returns the message header, if it exists. Otherwise it will generate one. @@ -1055,7 +1056,7 @@ def header(self): try: return self._header except AttributeError: - headerText = self._getStringStream('__substg1.0_007D') + headerText = self.headerText if headerText: self._header = EmailParser().parsestr(headerText) self._header['date'] = self.date @@ -1071,6 +1072,7 @@ def header(self): # TODO find authentication results outside of header header.add_header('Authentication-Results', None) self._header = header + return self._header @property @@ -1130,6 +1132,13 @@ def headerFormatProperties(self) -> constants.HEADER_FORMAT_TYPE: }, } + @functools.cached_property + def headerText(self) -> Optional[str]: + """ + The raw text of the header stream, if it exists. + """ + return self._getStringStream('__substg1.0_007D') + @property def htmlBody(self) -> Optional[bytes]: """ @@ -1229,7 +1238,7 @@ def messageId(self) -> Optional[str]: except AttributeError: headerResult = None if self.headerInit(): - headerResult = self._header['message-id'] + headerResult = self.header['message-id'] if headerResult is not None: self._messageId = headerResult else: @@ -1329,7 +1338,7 @@ def sender(self) -> Optional[str]: except AttributeError: # Check header first if self.headerInit(): - headerResult = self.header['from'] + headerResult = decodeRfc2047(self.header['from']) if headerResult is not None: self._sender = headerResult return headerResult diff --git a/extract_msg/utils.py b/extract_msg/utils.py index 1d919769..d9801e3a 100644 --- a/extract_msg/utils.py +++ b/extract_msg/utils.py @@ -25,6 +25,7 @@ import collections import copy import datetime +import email.header import email.message import email.policy import glob @@ -169,6 +170,21 @@ def _open(name, mode, *args, **kwargs): return _open +def decodeRfc2047(encoded : str) -> str: + """ + Decodes text encoded using the method specified in RFC 2047. + """ + # This returns a list of tuples containing the bytes and the encoding they + # are using, so we decode each one and join them together. + # + # decode_header header will return a string instead of bytes for the first + # object if the input is not encoded, something that is frustrating. + return ''.join( + x[0].decode(x[1] or 'ascii') if isinstance(x[0], bytes) else x + for x in email.header.decode_header(encoded) + ) + + def dictGetCasedKey(_dict : Dict, key : Any) -> Any: """ Retrieves the key from the dictionary with the proper casing using a From 9940fbac5927fb514f88835fafad6eb084a5e2a4 Mon Sep 17 00:00:00 2001 From: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> Date: Sun, 11 Jun 2023 16:59:32 +0200 Subject: [PATCH 5/8] Update tzlocal and red-black-tree-mod Fix for #366 --- CHANGELOG.md | 4 ++++ extract_msg/__init__.py | 4 ++-- extract_msg/utils.py | 2 +- requirements.txt | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00bb4278..757d4932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +**v0.41.4** +* Fixed [[TeamMsgExtractor #366](https://github.com/TeamMsgExtractor/msg-extractor/pull/366)] +* Updated `tzlocal` and `red-black-tree-mod` to allow other projects to update their dependency trees. + **v0.41.3** * [[TeamMsgExtractor #365](https://github.com/TeamMsgExtractor/msg-extractor/issues/365)] Fixed an issue that would cause certain values retrieved from the header to not be decoded properly. It does this when retrieving the values, so nothing about the header has been changed. * Added new property `MessageBase.headerText` which is the text content of the header stream. Adjusted other things to use this instead of trying to retrieve the stream directly in multiple places. diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index 0021ce89..3910d1a2 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -27,8 +27,8 @@ # along with this program. If not, see . __author__ = 'Destiny Peterson & Matthew Walker' -__date__ = '2023-06-10' -__version__ = '0.41.3' +__date__ = '2023-06-11' +__version__ = '0.41.4' __all__ = [ # Modules: diff --git a/extract_msg/utils.py b/extract_msg/utils.py index d9801e3a..76b8c380 100644 --- a/extract_msg/utils.py +++ b/extract_msg/utils.py @@ -180,7 +180,7 @@ def decodeRfc2047(encoded : str) -> str: # decode_header header will return a string instead of bytes for the first # object if the input is not encoded, something that is frustrating. return ''.join( - x[0].decode(x[1] or 'ascii') if isinstance(x[0], bytes) else x + x[0].decode(x[1] or 'ascii') if isinstance(x[0], bytes) else x[0] for x in email.header.decode_header(encoded) ) diff --git a/requirements.txt b/requirements.txt index 72792d2a..2ce9fff0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,10 @@ # First level requirements imapclient>=2.3.0,<3 olefile==0.46 -tzlocal==4.2 +tzlocal>=4.2,<6 compressed_rtf==1.0.6 ebcdic==1.1.1 beautifulsoup4>=4.11.1,<4.13 RTFDE==0.0.2 chardet>=4.0.0,<6 -red-black-tree-mod==1.20 +red-black-tree-mod>=1.20,<2 From 5f7dd4738859625b4af03fda8d77fef35c1e17c8 Mon Sep 17 00:00:00 2001 From: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> Date: Sun, 11 Jun 2023 17:57:57 +0200 Subject: [PATCH 6/8] Updated requirements and changelog --- CHANGELOG.md | 2 +- requirements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 757d4932..1f8992af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ **v0.41.4** * Fixed [[TeamMsgExtractor #366](https://github.com/TeamMsgExtractor/msg-extractor/pull/366)] -* Updated `tzlocal` and `red-black-tree-mod` to allow other projects to update their dependency trees. +* Updated `tzlocal` and allow future updates for `compressed_rtf` and `ebcdic`. **v0.41.3** * [[TeamMsgExtractor #365](https://github.com/TeamMsgExtractor/msg-extractor/issues/365)] Fixed an issue that would cause certain values retrieved from the header to not be decoded properly. It does this when retrieving the values, so nothing about the header has been changed. diff --git a/requirements.txt b/requirements.txt index 2ce9fff0..3125d5d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,9 +3,9 @@ imapclient>=2.3.0,<3 olefile==0.46 tzlocal>=4.2,<6 -compressed_rtf==1.0.6 -ebcdic==1.1.1 +compressed_rtf>=1.0.6,<2 +ebcdic>=1.1.1,<2 beautifulsoup4>=4.11.1,<4.13 RTFDE==0.0.2 chardet>=4.0.0,<6 -red-black-tree-mod>=1.20,<2 +red-black-tree-mod==1.20 From 991db10692a0892b0e6db62177859065211980e2 Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Sun, 11 Jun 2023 09:38:04 -0700 Subject: [PATCH 7/8] Update changelog format, update readme --- CHANGELOG.md | 2 +- README.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f8992af..c67d6df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ **v0.41.4** -* Fixed [[TeamMsgExtractor #366](https://github.com/TeamMsgExtractor/msg-extractor/pull/366)] +* Fixed an issue in the last version that would break the decoding function if the contents were not encoded. * Updated `tzlocal` and allow future updates for `compressed_rtf` and `ebcdic`. **v0.41.3** diff --git a/README.rst b/README.rst index 5516c8a7..663bf680 100644 --- a/README.rst +++ b/README.rst @@ -250,8 +250,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.3-blue.svg - :target: https://pypi.org/project/extract-msg/0.41.3/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.4-blue.svg + :target: https://pypi.org/project/extract-msg/0.41.4/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg :target: https://www.python.org/downloads/release/python-3816/ From 950731d43738afa97d545fdf78f26f4644a7f27d Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Sun, 11 Jun 2023 10:15:46 -0700 Subject: [PATCH 8/8] Fix another issue from 0.41.3 --- CHANGELOG.md | 3 +++ README.rst | 4 ++-- extract_msg/__init__.py | 2 +- extract_msg/message_base.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c67d6df8..0145e45d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +**v0.41.5** +* Fixed an issue from version `0.41.3` where the header being present but missing the `From` field would cause an exception. + **v0.41.4** * Fixed an issue in the last version that would break the decoding function if the contents were not encoded. * Updated `tzlocal` and allow future updates for `compressed_rtf` and `ebcdic`. diff --git a/README.rst b/README.rst index 663bf680..4020af6b 100644 --- a/README.rst +++ b/README.rst @@ -250,8 +250,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.4-blue.svg - :target: https://pypi.org/project/extract-msg/0.41.4/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.41.5-blue.svg + :target: https://pypi.org/project/extract-msg/0.41.5/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg :target: https://www.python.org/downloads/release/python-3816/ diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index 3910d1a2..088987ac 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -28,7 +28,7 @@ __author__ = 'Destiny Peterson & Matthew Walker' __date__ = '2023-06-11' -__version__ = '0.41.4' +__version__ = '0.41.5' __all__ = [ # Modules: diff --git a/extract_msg/message_base.py b/extract_msg/message_base.py index e9014bca..f126a923 100644 --- a/extract_msg/message_base.py +++ b/extract_msg/message_base.py @@ -1338,9 +1338,9 @@ def sender(self) -> Optional[str]: except AttributeError: # Check header first if self.headerInit(): - headerResult = decodeRfc2047(self.header['from']) + headerResult = self.header['from'] if headerResult is not None: - self._sender = headerResult + self._sender = decodeRfc2047(headerResult) return headerResult logger.info('Header found, but "sender" is not included. Will be generated from other streams.') # Extract from other fields