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

Account for broken outlines/annotations, where the destination dictionary contains an invalid /Dest entry

According to the specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=377, a `Dest` entry in an outline item should *not* contain a dictionary.
Unsurprisingly there's PDF generators that completely ignore this, treating is an `A` entry instead.

The patch also adds a little bit more validation code in `Catalog.parseDestDictionary`.
This commit is contained in:
Jonas Jenwald 2017-08-25 13:40:50 +02:00
parent bd85bda0a6
commit 42f2d36d1f
2 changed files with 48 additions and 7 deletions

View file

@ -689,6 +689,36 @@ describe('annotation', function() {
expect(data.dest).toEqual([{ num: 17, gen: 0, }, { name: 'XYZ', },
0, 841.89, null]);
});
it('should correctly parse a Dest, which violates the specification ' +
'by containing a dictionary', function() {
let destDict = new Dict();
destDict.set('Type', Name.get('Action'));
destDict.set('S', Name.get('GoTo'));
destDict.set('D', 'page.157');
let annotationDict = new Dict();
annotationDict.set('Type', Name.get('Annot'));
annotationDict.set('Subtype', Name.get('Link'));
// The /Dest must be a Name or an Array, refer to ISO 32000-1:2008
// section 12.3.3, but there are PDF files where it's a dictionary.
annotationDict.set('Dest', destDict);
let annotationRef = new Ref(798, 0);
let xref = new XRefMock([
{ ref: annotationRef, data: annotationDict, }
]);
let annotation = annotationFactory.create(xref, annotationRef,
pdfManagerMock, idFactoryMock);
let data = annotation.data;
expect(data.annotationType).toEqual(AnnotationType.LINK);
expect(data.url).toBeUndefined();
expect(data.unsafeUrl).toBeUndefined();
expect(data.dest).toEqual('page.157');
});
});
describe('WidgetAnnotation', function() {