Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NewReaderEncryptedaccepts only%PDF-1.0to%PDF-1.7directly followed by CR or LF, so it rejects two kinds of files with "not a PDF file: invalid header":%PDF-2.0(ISO 32000-2, 7.5.2), and pdfTeX and LuaTeX write it, for example.%PDF-1.1 \n(Handle space after header #22), and some writers put a NUL byte there.The check now accepts
%PDF-1.0to%PDF-1.7and%PDF-2.0, followed by any PDF white-space character. Anything else is still rejected.Test plan:
TestNewReaderAcceptsHeaders. It opens a one-page file with each of several headers and checksNumPage, and checks that%PDF-1.8,%PDF-2.1,%PDF-1.and%PDF-1.45are still rejected. Onmasterit fails for%PDF-2.0\n,%PDF-2.0\r,%PDF-1.1 \nand%PDF-1.2\x00\n.go test ./...andgo build ./...pass.qpdf --json, apart from one odd-length hex string that the reader fails on for a separate reason.NumPageagrees with qpdf on all 23, andGetPlainTextreturns no error.Fixes #22.