From 93830032ac22cb94ce79407d30d487f31f89a2ed Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 30 Sep 2016 11:44:24 +0200 Subject: [PATCH] Add a unit-test for annotations where the `URI` action has an incorrect encoding (bug 1122280, PR 5999) --- test/unit/annotation_layer_spec.js | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/unit/annotation_layer_spec.js b/test/unit/annotation_layer_spec.js index a1e38168e..ad3ba8a42 100644 --- a/test/unit/annotation_layer_spec.js +++ b/test/unit/annotation_layer_spec.js @@ -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'));