Merge pull request #15562 from Snuffleupagus/checkHeader-prefix
Slightly re-factor the version fetching in `PDFDocument.checkHeader`
This commit is contained in:
commit
21c2d0c7b0
@ -900,19 +900,19 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
stream.moveStart();
|
stream.moveStart();
|
||||||
|
|
||||||
|
// Skip over the "%PDF-" prefix, since it was found above.
|
||||||
|
stream.skip(PDF_HEADER_SIGNATURE.length);
|
||||||
// Read the PDF format version.
|
// Read the PDF format version.
|
||||||
const MAX_PDF_VERSION_LENGTH = 12;
|
|
||||||
let version = "",
|
let version = "",
|
||||||
ch;
|
ch;
|
||||||
while ((ch = stream.getByte()) > /* Space = */ 0x20) {
|
while (
|
||||||
if (version.length >= MAX_PDF_VERSION_LENGTH) {
|
(ch = stream.getByte()) > /* Space = */ 0x20 &&
|
||||||
break;
|
version.length < /* MAX_PDF_VERSION_LENGTH = */ 7
|
||||||
}
|
) {
|
||||||
version += String.fromCharCode(ch);
|
version += String.fromCharCode(ch);
|
||||||
}
|
}
|
||||||
if (!this._version) {
|
if (!this._version) {
|
||||||
// Remove the "%PDF-" prefix.
|
this._version = version;
|
||||||
this._version = version.substring(5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user