Change the assert in Parser.findDefaultInlineStreamEnd to a non-PRODUCTION one

Given that this `assert` is only intended to catch any implementation bugs in our code, and not actually to validate the PDF data directly[1], we can avoid making this function call unconditionally.

---
[1] In those cases, for example a `FormatError` should have been thrown instead.
This commit is contained in:
Jonas Jenwald 2022-11-12 16:11:56 +01:00
parent 2d1b1e7968
commit d22eb3591e

View File

@ -203,7 +203,12 @@ class Parser {
} else if (state === 1) {
state = ch === I ? 2 : 0;
} else {
assert(state === 2, "findDefaultInlineStreamEnd - invalid state.");
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(state === 2, "findDefaultInlineStreamEnd - invalid state.");
}
if (ch === SPACE || ch === LF || ch === CR) {
maybeEIPos = stream.pos;
// Let's check that the next `n` bytes are ASCII... just to be sure.