1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Ignore line-breaks between operator and digit in Lexer.getNumber

This is consistent with the behaviour in Adobe Reader (and PDFium), and it fixes the display of page 30 in https://bug1354114.bmoattachments.org/attachment.cgi?id=8855457 (taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1354114).

The patch also makes the `error` message for invalid numbers slightly more useful, by including the charCode as well. (Having that information available would have reduced the time spent on debugging the PDF file above.)
This commit is contained in:
Jonas Jenwald 2017-05-02 14:14:03 +02:00
parent aea3eccd0f
commit 40feca12c1
4 changed files with 33 additions and 2 deletions

View file

@ -721,9 +721,14 @@ var Lexer = (function LexerClosure() {
divideBy = 10;
ch = this.nextChar();
}
if (ch === 0x0A || ch === 0x0D) { // LF, CR
// Ignore line-breaks (this is consistent with Adobe Reader).
do {
ch = this.nextChar();
} while (ch === 0x0A || ch === 0x0D);
}
if (ch < 0x30 || ch > 0x39) { // '0' - '9'
error('Invalid number: ' + String.fromCharCode(ch));
return 0;
error(`Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`);
}
var baseValue = ch - 0x30; // '0'