mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Let Lexer.getNumber
treat a single minus sign as zero (bug 1753983)
This appears to be consistent with the behaviour in both Adobe Reader and PDFium (in Google Chrome); this is essentially the same approach as used for a single decimal point in PR 9827.
This commit is contained in:
parent
acc758c40c
commit
64f3dbeb48
5 changed files with 27 additions and 12 deletions
|
@ -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})`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue