mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Let Lexer.getNumber
treat a single decimal point as zero (issue 9252)
This is consistent with the behaviour in Adobe Reader.
This commit is contained in:
parent
df4799a12a
commit
6bbcafcd26
5 changed files with 127 additions and 3 deletions
|
@ -18,8 +18,8 @@ import {
|
|||
PredictorStream, RunLengthStream
|
||||
} from './stream';
|
||||
import {
|
||||
assert, FormatError, info, isNum, isString, MissingDataException, StreamType,
|
||||
warn
|
||||
assert, FormatError, info, isNum, isSpace, isString, MissingDataException,
|
||||
StreamType, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
Cmd, Dict, EOF, isCmd, isDict, isEOF, isName, Name, Ref
|
||||
|
@ -721,7 +721,7 @@ var Lexer = (function LexerClosure() {
|
|||
var ch = this.currentChar;
|
||||
var eNotation = false;
|
||||
var divideBy = 0; // different from 0 if it's a floating point value
|
||||
var sign = 1;
|
||||
var sign = 0;
|
||||
|
||||
if (ch === 0x2D) { // '-'
|
||||
sign = -1;
|
||||
|
@ -732,6 +732,7 @@ var Lexer = (function LexerClosure() {
|
|||
ch = this.nextChar();
|
||||
}
|
||||
} else if (ch === 0x2B) { // '+'
|
||||
sign = 1;
|
||||
ch = this.nextChar();
|
||||
}
|
||||
if (ch === 0x0A || ch === 0x0D) { // LF, CR
|
||||
|
@ -745,10 +746,17 @@ var Lexer = (function LexerClosure() {
|
|||
ch = this.nextChar();
|
||||
}
|
||||
if (ch < 0x30 || ch > 0x39) { // '0' - '9'
|
||||
if (divideBy === 10 && sign === 0 &&
|
||||
(isSpace(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;
|
||||
}
|
||||
throw new FormatError(
|
||||
`Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`);
|
||||
}
|
||||
|
||||
sign = sign || 1;
|
||||
var baseValue = ch - 0x30; // '0'
|
||||
var powerValue = 0;
|
||||
var powerValueSign = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue