Skip to content

Commit 7ed4223

Browse files
Merge pull request #293 from TeamMsgExtractor/next-release
v0.36.4
2 parents 6203061 + 357b5a4 commit 7ed4223

File tree

6 files changed

+46
-24
lines changed

6 files changed

+46
-24
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
custom: ['https://www.buymeacoffee.com/DestructionE', 'https://www.patreon.com/DestructionE']
1+
ko_fi: DestructionE
2+
patreon: DestructionE
3+
custom: ['https://www.buymeacoffee.com/DestructionE']

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
**v0.36.4**
2+
* [[TeamMsgExtractor #291](https://github.com/TeamMsgExtractor/msg-extractor/issues/291)] Fixed typo in `MSGFile.saveRaw` that may have existed for a significant amount of time. It was using the wrong function (same name, but with different capitalization) but was hidden until `MSGFile` stopped being derived from `OleFileIO`.
3+
* Added logging code to `MessageBase.getSavePdfBody` to log the list that is going to be used to run `wkhtmltopdf`. This is mainly for debugging purposes, to allow users to potentially see why their arguments may be failing.
4+
* Updating funding information on GitHub and the `README` with more ways to support the module's development.
5+
* Fixed one of the exceptions in `MessageBase.getSavePdfBody` not using an fstring which caused it to omit information.
6+
* Changed the way `wkhtmltopdf` is called to patch a possible security vulnerability. This also seems to have fixed [[TeamMsgExtractor #291](https://github.com/TeamMsgExtractor/msg-extractor/issues/291)].
7+
18
**v0.36.3**
29
* Added an option to skip the body if it could not be found, rather than throwing an error. This will cause no file to be made for it in the event no valid body exists. For the save functions, this option is `skipBodyNotFound` and from the command line the option is `--skip-body-not-found`.
310
* Fixed a bug that caused contacts to save the business phone with two colons instead of 1.

README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ Supporting The Module
147147
---------------------
148148

149149
If you'd like to donate to help support the development of the module, you can
150-
donate to Destiny at her Buy Me a Coffee page here: `Buy Me a Coffee`_
150+
donate to Destiny using one of the following services:
151+
* `Buy Me a Coffee`_
152+
* `Ko-fi`_
153+
* `Patreon`_
151154

152155
Installation
153156
------------
@@ -227,8 +230,8 @@ your access to the newest major version of extract-msg.
227230
.. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg
228231
:target: LICENSE.txt
229232

230-
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.3-blue.svg
231-
:target: https://pypi.org/project/extract-msg/0.36.3/
233+
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.4-blue.svg
234+
:target: https://pypi.org/project/extract-msg/0.36.4/
232235

233236
.. |PyPI2| image:: https://img.shields.io/badge/python-3.6+-brightgreen.svg
234237
:target: https://www.python.org/downloads/release/python-367/
@@ -242,4 +245,6 @@ your access to the newest major version of extract-msg.
242245
.. _Seamus Tuohy: https://github.com/seamustuohy
243246
.. _Discord: https://discord.com/invite/B77McRmzdc
244247
.. _Buy Me a Coffee: https://www.buymeacoffee.com/DestructionE
248+
.. _Ko-fi: https://ko-fi.com/destructione
249+
.. _Patreon: https://www.patreon.com/DestructionE
245250
.. _msg-explorer: https://pypi.org/project/msg-explorer/

extract_msg/__init__.py

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

2929
__author__ = 'Destiny Peterson & Matthew Walker'
30-
__date__ = '2022-08-29'
31-
__version__ = '0.36.3'
30+
__date__ = '2022-09-29'
31+
__version__ = '0.36.4'
3232

3333
import logging
3434

extract_msg/message_base.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,36 +372,44 @@ def getSavePdfBody(self, **kwargs) -> bytes:
372372
# Immediately try to find the executable.
373373
wkPath = findWk(kwargs.get('wkPath'))
374374

375-
# First thing is first, we need to parse our wkOptions if
376-
# they exist.
375+
# First thing is first, we need to parse our wkOptions if they exist.
377376
wkOptions = kwargs.get('wkOptions')
378377
if wkOptions:
379378
try:
380-
# Try to convert to a list, whatever it is, and
381-
# fail if it is not possible.
379+
# Try to convert to a list, whatever it is, and fail if it is
380+
# not possible.
382381
parsedWkOptions = [*wkOptions]
383382
except TypeError:
384-
raise TypeError(':param wkOptions: must be an iterable, not {type(wkOptions)}.')
383+
raise TypeError(f':param wkOptions: must be an iterable, not {type(wkOptions)}.')
385384
else:
386385
parsedWkOptions = []
387386

388-
# Confirm that all of our options we now have are either
389-
# strings or bytes.
387+
# Confirm that all of our options we now have are either strings or
388+
# bytes.
390389
if not all(isinstance(option, (str, bytes)) for option in parsedWkOptions):
391390
raise TypeError(':param wkOptions: must be an iterable of strings and bytes.')
392391

393-
# We call the program to convert the html, but give tell it
394-
# the data will go in and come out through stdin and stdout,
395-
# respectively. This way we don't have to write temporary
396-
# files to the disk. We also ask that it be quiet about it.
397-
process = subprocess.Popen([wkPath, *parsedWkOptions, '-', '-'], shell = True, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
398-
# Give the program the data and wait for the program to
399-
# finish.
400-
output = process.communicate(self.getSaveHtmlBody(**kwargs))
392+
processArgs = [wkPath, *parsedWkOptions, '-', '-']
393+
# Log the arguments.
394+
logger.info(f'Converting to PDF with the following arguments: {processArgs}')
395+
396+
397+
# Get the html body *before* calling Popen.
398+
htmlBody = self.getSaveHtmlBody(**kwargs)
399+
400+
# We call the program to convert the html, but give tell it the data
401+
# will go in and come out through stdin and stdout, respectively. This
402+
# way we don't have to write temporary files to the disk. We also ask
403+
# that it be quiet about it.
404+
process = subprocess.run(processArgs, input = htmlBody, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
405+
# Give the program the data and wait for the program to finish.
406+
#output = process.communicate(htmlBody)
407+
408+
# If it errored, throw it as an exception.
401409
if process.returncode != 0:
402-
raise WKError(output[1].decode('utf-8'))
410+
raise WKError(process.stderr.decode('utf-8'))
403411

404-
return output[0]
412+
return process.stdout
405413

406414
def getSaveRtfBody(self, **kwargs) -> bytes:
407415
"""

extract_msg/msg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def saveRaw(self, path):
523523
raise FileExistsError(f'File "{path}" already exists.')
524524
with zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED) as zfile:
525525
# Loop through all the directories
526-
for dir_ in self.listdir():
526+
for dir_ in self.listDir():
527527
sysdir = '/'.join(dir_)
528528
code = dir_[-1][-8:]
529529
if constants.PROPERTIES.get(code):

0 commit comments

Comments
 (0)