Skip to content

Commit

Permalink
fix: check for bad zip files during unzipping in file doctype (#19058) (
Browse files Browse the repository at this point in the history
#19060)

* check for bad zip files

(cherry picked from commit 5395744)

Co-authored-by: Nikhil <30789322+nk521@users.noreply.github.com>
  • Loading branch information
mergify[bot] and nk521 committed Nov 30, 2022
1 parent 1cd0bc2 commit 96c928e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frappe/core/doctype/file/file.py
Expand Up @@ -423,7 +423,10 @@ def unzip(self) -> list["File"]:
continue

file_doc = frappe.new_doc("File")
file_doc.content = z.read(file.filename)
try:
file_doc.content = z.read(file.filename)
except zipfile.BadZipFile:
frappe.throw(_("{0} is a not a valid zip file").format(self.file_name))
file_doc.file_name = filename
file_doc.folder = self.folder
file_doc.is_private = self.is_private
Expand Down

0 comments on commit 96c928e

Please sign in to comment.