Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent overwriting of the warnings by PyPDF2 #20170

Merged
merged 2 commits into from Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frappe/tests/test_pdf.py
Expand Up @@ -46,7 +46,7 @@ def test_read_options_from_html(self):
def test_pdf_encryption(self):
password = "qwe"
pdf = pdfgen.get_pdf(self.html, options={"password": password})
reader = PdfFileReader(io.BytesIO(pdf))
reader = PdfFileReader(io.BytesIO(pdf), overwriteWarnings=False)
self.assertTrue(reader.isEncrypted)
if six.PY2:
password = frappe.safe_encode(password)
Expand Down
2 changes: 1 addition & 1 deletion frappe/utils/pdf.py
Expand Up @@ -42,7 +42,7 @@ def get_pdf(html, options=None, output=None):

# https://pythonhosted.org/PyPDF2/PdfFileReader.html
# create in-memory binary streams from filedata and create a PdfFileReader object
reader = PdfFileReader(io.BytesIO(filedata))
reader = PdfFileReader(io.BytesIO(filedata), overwriteWarnings=False)
except OSError as e:
if any([error in str(e) for error in PDF_CONTENT_ERRORS]):
if not filedata:
Expand Down