|
1 | 1 | /* globals expect, it, describe, Dict, Name, Annotation, AnnotationBorderStyle,
|
2 | 2 | AnnotationBorderStyleType, AnnotationType, AnnotationFlag, PDFJS,
|
3 | 3 | beforeEach, afterEach, stringToBytes, AnnotationFactory, Ref, isRef,
|
4 |
| - beforeAll, afterAll, AnnotationFieldFlag */ |
| 4 | + beforeAll, afterAll, AnnotationFieldFlag, stringToUTF8String, |
| 5 | + StringStream, Lexer, Parser */ |
5 | 6 |
|
6 | 7 | 'use strict';
|
7 | 8 |
|
@@ -302,6 +303,38 @@ describe('Annotation layer', function() {
|
302 | 303 | expect(data.dest).toBeUndefined();
|
303 | 304 | });
|
304 | 305 |
|
| 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 | + |
305 | 338 | it('should correctly parse a GoTo action', function() {
|
306 | 339 | var actionDict = new Dict();
|
307 | 340 | actionDict.set('Type', Name.get('Action'));
|
|
0 commit comments