Skip to content

Commit

Permalink
use path in multipart attachment name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeleonard committed May 4, 2023
1 parent 31b7668 commit f2a7708
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion analyzers/EmlParser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ def parseEml(filepath, job_directory, wkhtmltoimage, sanitized_rendering):
for a in decoded_email.get("attachment"):
a["mime"] = magic.from_buffer(binascii.a2b_base64(a.get("raw")))
if isinstance(a.get("raw"), bytes):
filepath = os.path.join(job_directory, "output", a.get("filename", ""))
path, filename = os.path.split(a.get("filename", ""))
if path != "":
os.umask(0)
os.makedirs(
f"{job_directory}/output/{path}", exist_ok=True, mode=0o777
)
filepath = os.path.join(job_directory, "output", path, filename)
with open(filepath, "wb") as f:
f.write(base64.b64decode(a["raw"]))
f.close()
Expand Down

0 comments on commit f2a7708

Please sign in to comment.