calibre-web
calibre-web copied to clipboard
Fix http 500 error during pdf upload (NullObject object has no attribute 'split')
This fixes http 500 error during upload of some books that pass pdf 1.4 validation at https://www.pdf-online.com/osa/validate.aspx, but cause the error in calbre-web. The error message is:
File "/app/calibre-web/cps/editbooks.py", line 1001, in edit_book_tags
input_tags = tags.split(',')
AttributeError: 'NullObject' object has no attribute 'split'
Example of a book (21MB) that causes the error: https://github.com/contributor/calibre-web/blob/test-case/test/dotnet-aspire_cropped.pdf
NullObject comes from parsing metadata by pypdf/pypdf2/pypdf3 package.
This PR fixes http 500 error by ignoring 'NullObject /Keywords' and contains two commits:
- the first commit does it “the right way”
- the second commit does it “the simple way”: it avoids importing NullObject from three packages and localizes fix in single place
@OzzieIsaacs thank you for all your work! If you prefer commit 1, I will drop commit 2. If you prefer commit 2, you can just squash the PR during merge