1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #14543 from Snuffleupagus/bug-1753983

Let `Lexer.getNumber` treat a single minus sign as zero (bug 1753983)
This commit is contained in:
Brendan Dahl 2022-02-09 14:06:35 -08:00 committed by GitHub
commit f8b2a99ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 12 deletions

View file

@ -4561,7 +4561,7 @@ class EvaluatorPreprocessor {
}
static get MAX_INVALID_PATH_OPS() {
return shadow(this, "MAX_INVALID_PATH_OPS", 20);
return shadow(this, "MAX_INVALID_PATH_OPS", 10);
}
constructor(stream, xref, stateManager = new StateManager()) {

View file

@ -908,14 +908,17 @@ class Lexer {
ch = this.nextChar();
}
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
if (
divideBy === 10 &&
sign === 0 &&
(isWhiteSpace(ch) || ch === /* EOF = */ -1)
) {
if (isWhiteSpace(ch) || ch === /* EOF = */ -1) {
// This is consistent with Adobe Reader (fixes issue9252.pdf).
warn("Lexer.getNumber - treating a single decimal point as zero.");
return 0;
if (divideBy === 10 && sign === 0) {
warn("Lexer.getNumber - treating a single decimal point as zero.");
return 0;
}
// This is consistent with Adobe Reader (fixes bug1753983.pdf).
if (divideBy === 0 && sign === -1) {
warn("Lexer.getNumber - treating a single minus sign as zero.");
return 0;
}
}
throw new FormatError(
`Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`