Merge pull request #12516 from Snuffleupagus/fieldObjects-annotation-undefined

Prevent issues, in `PDFDocument.fieldObjects`, for invalid Annotations
This commit is contained in:
Tim van der Meij 2020-10-24 15:42:33 +02:00 committed by GitHub
commit c493dc96fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -969,7 +969,7 @@ class PDFDocument {
this.pdfManager,
this._localIdFactory
)
.then(annotation => annotation.getFieldObject())
.then(annotation => annotation && annotation.getFieldObject())
.catch(function (reason) {
warn(`_collectFieldObjects: "${reason}".`);
return null;
@ -999,7 +999,7 @@ class PDFDocument {
for (const [name, promises] of fieldPromises) {
allPromises.push(
Promise.all(promises).then(fields => {
fields = fields.filter(field => field !== null);
fields = fields.filter(field => !!field);
if (fields.length > 0) {
allFields[name] = fields;
}