1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19647 from Snuffleupagus/bug-1953099

Let `Lexer.prototype.getNumber` treat more cases of a single minus sign as zero (bug 1953099)
This commit is contained in:
Jonas Jenwald 2025-03-12 19:34:07 +01:00 committed by GitHub
commit bec6287b0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 3 deletions

View file

@ -933,9 +933,14 @@ class Lexer {
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
if (isWhiteSpace(ch) || ch === /* EOF = */ -1) {
if (
isWhiteSpace(ch) ||
/* '(' = */ ch === 0x28 ||
/* '<' = */ ch === 0x3c ||
ch === /* EOF = */ -1
) {
// This is consistent with Adobe Reader (fixes issue9252.pdf,
// issue15604.pdf, bug1753983.pdf).
// issue15604.pdf, bug1753983.pdf, bug1953099.pdf).
info(`Lexer.getNumber - "${msg}".`);
return 0;
}

View file

@ -16,6 +16,7 @@
!bug1727053.pdf
!issue18408_reduced.pdf
!bug1907000_reduced.pdf
!bug1953099.pdf
!issue11913.pdf
!issue2391-1.pdf
!issue2391-2.pdf

BIN
test/pdfs/bug1953099.pdf Normal file

Binary file not shown.

View file

@ -10414,6 +10414,14 @@
"link": true,
"type": "eq"
},
{
"id": "bug1953099",
"file": "pdfs/bug1953099.pdf",
"md5": "15295cfa4999ccc08442423fca96c28f",
"rounds": 1,
"link": false,
"type": "eq"
},
{
"id": "bug1899804_print",
"file": "pdfs/bug1899804.pdf",

View file

@ -152,7 +152,17 @@ describe("parser", function () {
});
it("should treat a single decimal point, or minus/plus sign, as zero", function () {
const validNums = [".", "-", "+", "-.", "+.", "-\r\n.", "+\r\n."];
const validNums = [
".",
"-",
"+",
"-.",
"+.",
"-\r\n.",
"+\r\n.",
"-(",
"-<",
];
for (const number of validNums) {
const validInput = new StringStream(number);
const validLexer = new Lexer(validInput);