Let Lexer.prototype.getNumber treat more cases of a single minus sign as zero (bug 1953099)
This patch extends the approach of PR 14543, by also treating e.g. minus signs followed by '(' or '<' as zero.
Inside of a /Contents stream those characters will generally mean the start of one or more glyphs.
This commit is contained in:
parent
d74619847d
commit
ee34c5c648
@ -933,9 +933,14 @@ class Lexer {
|
|||||||
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
|
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
|
||||||
const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
|
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,
|
// This is consistent with Adobe Reader (fixes issue9252.pdf,
|
||||||
// issue15604.pdf, bug1753983.pdf).
|
// issue15604.pdf, bug1753983.pdf, bug1953099.pdf).
|
||||||
info(`Lexer.getNumber - "${msg}".`);
|
info(`Lexer.getNumber - "${msg}".`);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -16,6 +16,7 @@
|
|||||||
!bug1727053.pdf
|
!bug1727053.pdf
|
||||||
!issue18408_reduced.pdf
|
!issue18408_reduced.pdf
|
||||||
!bug1907000_reduced.pdf
|
!bug1907000_reduced.pdf
|
||||||
|
!bug1953099.pdf
|
||||||
!issue11913.pdf
|
!issue11913.pdf
|
||||||
!issue2391-1.pdf
|
!issue2391-1.pdf
|
||||||
!issue2391-2.pdf
|
!issue2391-2.pdf
|
||||||
|
|||||||
BIN
test/pdfs/bug1953099.pdf
Normal file
BIN
test/pdfs/bug1953099.pdf
Normal file
Binary file not shown.
@ -10414,6 +10414,14 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "bug1953099",
|
||||||
|
"file": "pdfs/bug1953099.pdf",
|
||||||
|
"md5": "15295cfa4999ccc08442423fca96c28f",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "bug1899804_print",
|
"id": "bug1899804_print",
|
||||||
"file": "pdfs/bug1899804.pdf",
|
"file": "pdfs/bug1899804.pdf",
|
||||||
|
|||||||
@ -152,7 +152,17 @@ describe("parser", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should treat a single decimal point, or minus/plus sign, as zero", 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) {
|
for (const number of validNums) {
|
||||||
const validInput = new StringStream(number);
|
const validInput = new StringStream(number);
|
||||||
const validLexer = new Lexer(validInput);
|
const validLexer = new Lexer(validInput);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user