1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Avoid infinite loop when getting annotation field name

- aims to fix issue #12963;
 - use a Set to track already visited objects;
 - remove the loop limit in getInheritableProperty and use a RefSet too.
This commit is contained in:
Calixte Denizet 2021-02-06 12:23:35 +01:00
parent f892c00275
commit 0fc8267576
6 changed files with 39 additions and 36 deletions

View file

@ -76,6 +76,7 @@
!issue8798r.pdf
!issue8823.pdf
!issue9084.pdf
!issue12963.pdf
!issue9105_reduced.pdf
!issue9252.pdf
!issue9262_reduced.pdf

BIN
test/pdfs/issue12963.pdf Normal file

Binary file not shown.

View file

@ -2445,6 +2445,15 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "issue12963",
"file": "pdfs/issue12963.pdf",
"md5": "2590047a2ef0113e698d888c29918008",
"rounds": 1,
"firstPage": 1,
"lastPage": 1,
"type": "eq",
"annotations": true
},
{ "id": "multiple-filters-length-zero",
"file": "pdfs/multiple-filters-length-zero.pdf",
"md5": "c273c3a6fb79cbf3034fe1b62b204728",

View file

@ -123,30 +123,6 @@ describe("core_utils", function () {
["qux2", "quux"],
]);
});
it("stops searching when the loop limit is reached", function () {
const dict = new Dict();
let currentDict = dict;
let parentDict = null;
// Exceed the loop limit of 100.
for (let i = 0; i < 150; i++) {
parentDict = new Dict();
currentDict.set("Parent", parentDict);
currentDict = parentDict;
}
parentDict.set("foo", "bar"); // Never found because of loop limit.
expect(getInheritableProperty({ dict, key: "foo" })).toEqual(undefined);
dict.set("foo", "baz");
expect(
getInheritableProperty({
dict,
key: "foo",
getArray: false,
stopWhenFound: false,
})
).toEqual(["baz"]);
});
});
describe("toRomanNumerals", function () {