Skip to content

Commit

Permalink
URL annotations handled as UTF-8 to accomodate some bad PDFs. For pro…
Browse files Browse the repository at this point in the history
…per 7-bit ASCII this makes no difference. Fixes Bug 1122280.
  • Loading branch information
hellemar committed May 10, 2015
1 parent 1a3310d commit c8db9eb
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.

This comment has been minimized.

Copy link
@timvandermeij

timvandermeij May 10, 2015

Could you add a reference to Bugzilla bug 1122280 here so that it is clear why this piece of code has been added?

try {
data.url = stringToUTF8String(url);
} catch (e) {
// Fall back to a simple copy. TODO: indicate error?

This comment has been minimized.

Copy link
@timvandermeij

timvandermeij May 10, 2015

I don't think we need to indicate any error here. PDFs with such URIs are rare, so a fallback should be enough.

data.url = url;
}
} else if (linkType === 'GoTo') {
data.dest = action.get('D');
} else if (linkType === 'GoToR') {
Expand Down

0 comments on commit c8db9eb

Please sign in to comment.