1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Prevent errors when parsing Annotations with missing (or invalid) /Subtype entries (issue 7446)

Note that I used a separate warning message for this case, instead of utilizing the same one as in the unsupported subtype case, to more clearly indicate that the PDF file itself is to blame rather than PDF.js.

Fixes 7446.
This commit is contained in:
Jonas Jenwald 2016-07-24 14:32:48 +02:00
parent 5678486802
commit 558a22cd02
5 changed files with 106 additions and 35 deletions

View file

@ -74,13 +74,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
// Determine the annotation's subtype.
var subtype = dict.get('Subtype');
subtype = isName(subtype) ? subtype.name : '';
subtype = isName(subtype) ? subtype.name : null;
// Return the right annotation object based on the subtype and field type.
var parameters = {
xref: xref,
dict: dict,
ref: ref
ref: ref,
subtype: subtype,
};
switch (subtype) {
@ -116,8 +117,12 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
return new FileAttachmentAnnotation(parameters);
default:
warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation');
if (!subtype) {
warn('Annotation is missing the required /Subtype.');
} else {
warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation.');
}
return new Annotation(parameters);
}
}
@ -181,7 +186,7 @@ var Annotation = (function AnnotationClosure() {
// Expose public properties using a data object.
this.data = {};
this.data.id = params.ref.toString();
this.data.subtype = dict.get('Subtype').name;
this.data.subtype = params.subtype;
this.data.annotationFlags = this.flags;
this.data.rect = this.rectangle;
this.data.color = this.color;