Skip to content

Commit d2a4974

Browse files
authored
Merge pull request mozilla#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)
2 parents 1564dc3 + 9383003 commit d2a4974

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

test/unit/annotation_layer_spec.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* globals expect, it, describe, Dict, Name, Annotation, AnnotationBorderStyle,
22
AnnotationBorderStyleType, AnnotationType, AnnotationFlag, PDFJS,
33
beforeEach, afterEach, stringToBytes, AnnotationFactory, Ref, isRef,
4-
beforeAll, afterAll, AnnotationFieldFlag */
4+
beforeAll, afterAll, AnnotationFieldFlag, stringToUTF8String,
5+
StringStream, Lexer, Parser */
56

67
'use strict';
78

@@ -302,6 +303,38 @@ describe('Annotation layer', function() {
302303
expect(data.dest).toBeUndefined();
303304
});
304305

306+
it('should correctly parse a URI action, where the URI entry ' +
307+
'has an incorrect encoding (bug 1122280)', function () {
308+
var actionStream = new StringStream(
309+
'<<\n' +
310+
'/Type /Action\n' +
311+
'/S /URI\n' +
312+
'/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n' +
313+
'>>\n'
314+
);
315+
var lexer = new Lexer(actionStream);
316+
var parser = new Parser(lexer);
317+
var actionDict = parser.getObj();
318+
319+
var annotationDict = new Dict();
320+
annotationDict.set('Type', Name.get('Annot'));
321+
annotationDict.set('Subtype', Name.get('Link'));
322+
annotationDict.set('A', actionDict);
323+
324+
var annotationRef = new Ref(8, 0);
325+
var xref = new XRefMock([
326+
{ ref: annotationRef, data: annotationDict, }
327+
]);
328+
329+
var annotation = annotationFactory.create(xref, annotationRef);
330+
var data = annotation.data;
331+
expect(data.annotationType).toEqual(AnnotationType.LINK);
332+
333+
expect(data.url).toEqual(
334+
stringToUTF8String('http://www.example.com/üöä'));
335+
expect(data.dest).toBeUndefined();
336+
});
337+
305338
it('should correctly parse a GoTo action', function() {
306339
var actionDict = new Dict();
307340
actionDict.set('Type', Name.get('Action'));

0 commit comments

Comments
 (0)