Opened 6 years ago
Closed 6 years ago
#1754 closed enhancement (fixed)
[PATCH] MIME type sniffing of PDFs is too strict for some real-world files
| Reported by: | ajlyon | Owned by: | simon |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | ingester | Version: | 2.1 |
| Keywords: | Cc: |
Description
In the Frontiers translator just committed (r7536), PDF saving would not work because the server was sending PDF files that started with a six digit hexadecimal and endline-- they were then rejected by the MIME type sniffing in xpcom/mime.js. Full discussion here: http://groups.google.com/group/zotero-dev/t/d9bbf5edc49f106a
This issue has not been noted for any other sites, but it seems quite possible that there are other cases where Zotero has blocked the attachment of PDFs for small deviation from spec, but no one has noticed.
The PDFs in question open properly in all tested PDF readers.
A potential fix for this and other cases of not-quite-legal PDFs would be to look for the string "%PDF-" anywhere in the first 128 bytes (suggested by Jason Friedman, author of the translator).
The attached patch versus trunk addresses this issue.
Attachments (1)
Change History (2)
Changed 6 years ago by ajlyon
comment:1 Changed 6 years ago by dstillman
- Resolution set to fixed
- Status changed from new to closed
(In [7614]) Closes #1754, [PATCH] MIME type sniffing of PDFs is too strict for some real-world files
Look for "%PDF-" anywhere in the first 128 bytes