Skip to content

Commit

Permalink
Minor fix for version. Now ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheElementalOfDestruction committed Jan 17, 2022
1 parent 73b3a23 commit 194495c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**v0.29.2**
* Fixed issue where the RTF injection was accidentally doing HTML escapes for non-encapsulated streams and *not* doing escapes for encapsulated streams.
* Fixed name error in `Message.save` causing bad logic. For context, the internal variable `zip` was renamed to `_zip` to avoid a name conflict with the built-in function. Some instances of it were missed.

**v0.29.1**
* [[TeamMsgExtractor #198](https://github.com/TeamMsgExtractor/msg-extractor/issues/198)] Added a feature to save the header in it's own file (prefers the full raw header if it can find it, otherwise puts in a generated one) that was actually supposed to be in v0.29.0 but I forgot, lol.
Expand Down
24 changes: 12 additions & 12 deletions extract_msg/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,24 @@ def save(self, **kwargs):
filename = name[:maxNameLength - len(ext)] + ext

# Check if we are doing a zip file.
zip = kwargs.get('zip')
_zip = kwargs.get('zip')


# ZipFile handling.
if zip:
if _zip:
# If we are doing a zip file, first check that we have been given a path.
if isinstance(zip, constants.STRING):
if isinstance(_zip, constants.STRING):
# If we have a path then we use the zip file.
zip = zipfile.ZipFile(zip, 'a', zipfile.ZIP_DEFLATED)
kwargs['zip'] = zip
_zip = zipfile.ZipFile(_zip, 'a', zipfile.ZIP_DEFLATED)
kwargs['zip'] = _zip
createdZip = True
else:
createdZip = False
# Path needs to be done in a special way if we are in a zip file.
customPath = kwargs.get('customPath', '').replace('\\', '/')
customPath += '/' if customPath and customPath[-1] != '/' else ''
# Set the open command to be that of the zip file.
_open = zip.open
_open = _zip.open
# Zip files use w for writing in binary.
mode = 'w'
else:
Expand All @@ -159,9 +159,9 @@ def save(self, **kwargs):
fullFilename = customPath + filename

if self.__type == 'data':
if zip:
if _zip:
name, ext = os.path.splitext(filename)
nameList = zip.namelist()
nameList = _zip.namelist()
if fullFilename in nameList:
for i in range(2, 100):
testName = customPath + name + ' (' + str(i) + ')' + ext
Expand Down Expand Up @@ -189,16 +189,16 @@ def save(self, **kwargs):
f.write(self.__data)

# Close the ZipFile if this function created it.
if zip and createdZip:
zip.close()
if _zip and createdZip:
_zip.close()

return fullFilename
else:
self.saveEmbededMessage(**kwargs)

# Close the ZipFile if this function created it.
if zip and createdZip:
zip.close()
if _zip and createdZip:
_zip.close()

return self.msg

Expand Down
8 changes: 4 additions & 4 deletions extract_msg/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def save(self, **kwargs):
path += self.defaultFolderName[:maxNameLength]

# Create the folders.
if not zip:
if not _zip:
try:
makeDirs(path)
except Exception:
Expand Down Expand Up @@ -266,13 +266,13 @@ def save(self, **kwargs):
f.write(inputToBytes(self.body, 'utf-8'))

except Exception:
if not zip:
if not _zip:
self.saveRaw(path)
raise
finally:
# Close the ZipFile if this function created it.
if zip and createdZip:
zip.close()
if _zip and createdZip:
_zip.close()

# Return the instance so that functions can easily be chained.
return self

0 comments on commit 194495c

Please sign in to comment.