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

Add a unit-test for annotations where the URI action has an incorrect encoding (bug 1122280, PR 5999)

This commit is contained in:
Jonas Jenwald 2016-09-30 11:44:24 +02:00
parent 1564dc311a
commit 93830032ac

View file

@ -1,7 +1,8 @@
/* globals expect, it, describe, Dict, Name, Annotation, AnnotationBorderStyle,
AnnotationBorderStyleType, AnnotationType, AnnotationFlag, PDFJS,
beforeEach, afterEach, stringToBytes, AnnotationFactory, Ref, isRef,
beforeAll, afterAll, AnnotationFieldFlag */
beforeAll, afterAll, AnnotationFieldFlag, stringToUTF8String,
StringStream, Lexer, Parser */
'use strict';
@ -302,6 +303,38 @@ describe('Annotation layer', function() {
expect(data.dest).toBeUndefined();
});
it('should correctly parse a URI action, where the URI entry ' +
'has an incorrect encoding (bug 1122280)', function () {
var actionStream = new StringStream(
'<<\n' +
'/Type /Action\n' +
'/S /URI\n' +
'/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n' +
'>>\n'
);
var lexer = new Lexer(actionStream);
var parser = new Parser(lexer);
var actionDict = parser.getObj();
var annotationDict = new Dict();
annotationDict.set('Type', Name.get('Annot'));
annotationDict.set('Subtype', Name.get('Link'));
annotationDict.set('A', actionDict);
var annotationRef = new Ref(8, 0);
var xref = new XRefMock([
{ ref: annotationRef, data: annotationDict, }
]);
var annotation = annotationFactory.create(xref, annotationRef);
var data = annotation.data;
expect(data.annotationType).toEqual(AnnotationType.LINK);
expect(data.url).toEqual(
stringToUTF8String('http://www.example.com/üöä'));
expect(data.dest).toBeUndefined();
});
it('should correctly parse a GoTo action', function() {
var actionDict = new Dict();
actionDict.set('Type', Name.get('Action'));