Fix PDF magic number sniffing matching anywhere in first 200 bytes

The %PDF- sniffer entry had no offset constraint, so it matched anywhere
in the file sample. This could cause ZIP files containing PDFs to be
misidentified as application/pdf when opened, since %PDF- could appear
within the first 200 bytes of the archive. Pin the match to offset 0,
where it must appear in a valid PDF.

Fixes https://forums.zotero.org/discussion/130161/zip-files-and-indexing
This commit is contained in:
Dan Stillman 2026-03-06 00:30:45 -05:00
parent 81f80a62e3
commit e60bf91e31

View file

@ -31,7 +31,7 @@ Zotero.MIME = new function () {
// Magic numbers -- see https://en.wikipedia.org/wiki/List_of_file_signatures
var _snifferEntries = [
["%PDF-", "application/pdf"],
["%PDF-", "application/pdf", 0],
["%!PS-Adobe-", 'application/postscript', 0],
["%! PS-Adobe-", 'application/postscript', 0],
["From", 'text/plain', 0],