4 ms·
Doesn't a PDF detector only need to check if the first few bytes are '%PDF-1.' ? That is, do you need a "valid PDF" detector or "more likely a PDF than anythin
by eesmith 7y ago
Doesn't a PDF detector only need to check if the first few bytes are '%PDF-1.' ?
That is, do you need a "valid PDF" detector or "more likely a PDF than anything else" detector?
- rovr138 7y agoDepends. If you need to parse it, that might still cause errors.
- eesmith 7y agoAgreed. Though when I think of "detector" I think more of https://en.wikipedia.org/wiki/File_(command) https://en.wikipedia.org/wiki/File_(command) and not something which verifies the file is in the correct format.
- BiteCode_dev 7y agoWell... file 'setupTests.ts' setupTests.ts: Java source, ASCII text I wouldn't put too much trust in file.
- klodolph 7y agoI don’t know what you expected. File is just there to give a good guess at a file’s format. There are a ton of reasons why this problem is hard, and there are reasons to make “file” less accurate in order to make the implementation simpler and more secure. But it will work fine for PDFs, often enough.
- jtvjan 7y agoThe heuristic used for Java source looks like this: 0 regex \^import.*;$ Java source
- deleted 7y ago[deleted]
- jahewson 7y agoRealistically, yes, but strictly speaking PDFs start with a footer and most PDF readers will accept highly corrupt files.