Skip to content

Commit

Permalink
Merge pull request #5999 from hellemar/handle-utf8-in-url
Browse files Browse the repository at this point in the history
Bug 1122280 - Handle UTF-8 encoding in URI
  • Loading branch information
timvandermeij committed May 14, 2015
2 parents d484ebd + a61a4b1 commit 67816bd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/core/annotation.js
Expand Up @@ -16,7 +16,8 @@
*/
/* globals PDFJS, Util, isDict, isName, stringToPDFString, warn, Dict, Stream,
stringToBytes, assert, Promise, isArray, ObjectLoader, OperatorList,
isValidUrl, OPS, createPromiseCapability, AnnotationType */
isValidUrl, OPS, createPromiseCapability, AnnotationType,
stringToUTF8String */

'use strict';

Expand Down Expand Up @@ -500,7 +501,15 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
if (!isValidUrl(url, false)) {
url = '';
}
data.url = url;
// According to ISO 32000-1:2008, section 12.6.4.7,
// URI should to be encoded in 7-bit ASCII.
// Some bad PDFs may have URIs in UTF-8 encoding, see Bugzilla 1122280.
try {
data.url = stringToUTF8String(url);
} catch (e) {
// Fall back to a simple copy.
data.url = url;
}
} else if (linkType === 'GoTo') {
data.dest = action.get('D');
} else if (linkType === 'GoToR') {
Expand Down

0 comments on commit 67816bd

Please sign in to comment.