Skip to content

Commit

Permalink
Merge pull request #17233 from calixteman/issue17232
Browse files Browse the repository at this point in the history
Don't try to collect a nonexistent field because of an invalid ref
  • Loading branch information
calixteman authored Nov 7, 2023
2 parents 72338ce + acc62f8 commit c6a717f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,9 @@ class PDFDocument {

#collectFieldObjects(name, fieldRef, promises, annotationGlobals) {
const field = this.xref.fetchIfRef(fieldRef);
if (!(field instanceof Dict)) {
return;
}
if (field.has("T")) {
const partName = stringToPDFString(field.get("T"));
name = name === "" ? partName : `${name}.${partName}`;
Expand All @@ -1737,8 +1740,9 @@ class PDFDocument {
})
);

if (field.has("Kids")) {
for (const kid of field.get("Kids")) {
const kids = field.get("Kids");
if (Array.isArray(kids)) {
for (const kid of kids) {
this.#collectFieldObjects(name, kid, promises, annotationGlobals);
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/pdfs/issue17232.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/mozilla/pdf.js/files/13280636/aanvraag-beeindiging-aansluiting.pdf

11 changes: 10 additions & 1 deletion test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8197,5 +8197,14 @@
"rounds": 1,
"type": "eq",
"annotations": true
}
},
{
"id": "issue17232-annotations",
"file": "pdfs/issue17232.pdf",
"md5": "90ade9fc5721ddf8d17e8cfc43e186a4",
"rounds": 1,
"link": true,
"type": "eq",
"annotations": true
}
]

0 comments on commit c6a717f

Please sign in to comment.