mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48: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
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -65,6 +65,7 @@
|
|||
!issue8823.pdf
|
||||
!issue9084.pdf
|
||||
!issue9105_reduced.pdf
|
||||
!issue9252.pdf
|
||||
!issue9262_reduced.pdf
|
||||
!issue9291.pdf
|
||||
!issue9458.pdf
|
||||
|
|
90
test/pdfs/issue9252.pdf
Normal file
90
test/pdfs/issue9252.pdf
Normal file
|
@ -0,0 +1,90 @@
|
|||
%PDF-1.4
|
||||
1 0 obj
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Version /1.4
|
||||
/Pages 5 0 R
|
||||
/Outlines 3 0 R
|
||||
>>
|
||||
endobj
|
||||
2 0 obj
|
||||
<<
|
||||
/Title (Test)
|
||||
/Author (Test)
|
||||
/Creator (sharpPDF)
|
||||
/CreationDate (2017124)
|
||||
>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Outlines
|
||||
/Count 0
|
||||
>>
|
||||
endobj
|
||||
4 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/Name /F1
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/Count 1
|
||||
/Kids [6 0 R ]
|
||||
>>
|
||||
endobj
|
||||
6 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 5 0 R
|
||||
/Resources <</Font <</F1 4 0 R >>
|
||||
>>
|
||||
/MediaBox [0 0 612 792]
|
||||
/CropBox [0 0 612 792]
|
||||
/Rotate 0
|
||||
/ProcSet [/PDF /Text /ImageC]
|
||||
/Contents [7 0 R ]
|
||||
>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<<
|
||||
/Filter [/ASCIIHexDecode]
|
||||
/Length 105
|
||||
>>
|
||||
stream
|
||||
710A42540A2F46312031352054660A2E202E3539202E38342072670A3530203735302054640A28546573742920546A0A45540A51>
|
||||
endstream
|
||||
endobj
|
||||
0 19
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000000098 00000 n
|
||||
0000000202 00000 n
|
||||
0000000254 00000 n
|
||||
0000000370 00000 n
|
||||
0000000491 00000 n
|
||||
0000000615 00000 n
|
||||
0000000743 00000 n
|
||||
0000000857 00000 n
|
||||
0000000976 00000 n
|
||||
0000001099 00000 n
|
||||
0000001226 00000 n
|
||||
0000001345 00000 n
|
||||
0000001464 00000 n
|
||||
0000001585 00000 n
|
||||
0000001710 00000 n
|
||||
0000001777 00000 n
|
||||
0000002102 00000 n
|
||||
trailer
|
||||
<<
|
||||
/Size 102
|
||||
/Root 1 0 R
|
||||
/Info 2 0 R
|
||||
>>
|
||||
startxref
|
||||
36673
|
||||
%%EOF
|
|
@ -741,6 +741,13 @@
|
|||
"lastPage": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue9252",
|
||||
"file": "pdfs/issue9252.pdf",
|
||||
"md5": "c7d039d808d9344a95d2c9cfa7586ca3",
|
||||
"rounds": 1,
|
||||
"link": false,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue9262",
|
||||
"file": "pdfs/issue9262_reduced.pdf",
|
||||
"md5": "5347ce2d7b3866625c22e115fd90e0de",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
import { Lexer, Linearization } from '../../src/core/parser';
|
||||
import { FormatError } from '../../src/shared/util';
|
||||
import { Name } from '../../src/core/primitives';
|
||||
import { StringStream } from '../../src/core/stream';
|
||||
|
||||
|
@ -69,6 +70,23 @@ describe('parser', function() {
|
|||
expect(plusLexer.getNumber()).toEqual(205.88);
|
||||
});
|
||||
|
||||
it('should treat a single decimal point as zero', function() {
|
||||
let input = new StringStream('.');
|
||||
let lexer = new Lexer(input);
|
||||
|
||||
expect(lexer.getNumber()).toEqual(0);
|
||||
|
||||
let numbers = ['..', '-.', '+.', '-\r\n.', '+\r\n.'];
|
||||
for (let number of numbers) {
|
||||
let input = new StringStream(number);
|
||||
let lexer = new Lexer(input);
|
||||
|
||||
expect(function() {
|
||||
return lexer.getNumber();
|
||||
}).toThrowError(FormatError, /^Invalid number:\s/);
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle glued numbers and operators', function() {
|
||||
var input = new StringStream('123ET');
|
||||
var lexer = new Lexer(input);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue