Merge pull request #7681 from Snuffleupagus/bug-1122280-unit-test

Add a unit-test for annotations where the `URI` action has an incorrect encoding (bug 1122280, PR 5999)
This commit is contained in:
Yury Delendik 2016-09-30 08:28:23 -05:00 committed by GitHub
commit d2a4974785

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'));