Browse Source

PDF.js version 1.4.248 - See mozilla/pdf.js@452c031af5a1242a632bc4276dc778b8d2970b7e

master v1.4.248
Pdf Bot 9 years ago
parent
commit
82ee15489d
  1. 2
      bower.json
  2. 147
      build/pdf.combined.js
  3. 24
      build/pdf.js
  4. 129
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.4.244", "version": "1.4.248",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

147
build/pdf.combined.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {}));
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.4.244'; var pdfjsVersion = '1.4.248';
var pdfjsBuild = 'ff65c80'; var pdfjsBuild = '452c031';
var pdfjsFilePath = var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ? typeof document !== 'undefined' && document.currentScript ?
@ -2354,7 +2354,7 @@ function isSameOrigin(baseUrl, otherUrl) {
// Validates if URL is safe and allowed, e.g. to avoid XSS. // Validates if URL is safe and allowed, e.g. to avoid XSS.
function isValidUrl(url, allowRelative) { function isValidUrl(url, allowRelative) {
if (!url) { if (!url || typeof url !== 'string') {
return false; return false;
} }
// RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1) // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
@ -19772,15 +19772,15 @@ var LinkTargetStringMap = [
/** /**
* @typedef ExternalLinkParameters * @typedef ExternalLinkParameters
* @typedef {Object} ExternalLinkParameters * @typedef {Object} ExternalLinkParameters
* @property {string} url * @property {string} url - An absolute URL.
* @property {LinkTarget} target * @property {LinkTarget} target - The link target.
* @property {string} rel * @property {string} rel - The link relationship.
*/ */
/** /**
* Adds various attributes (href, title, target, rel) to hyperlinks. * Adds various attributes (href, title, target, rel) to hyperlinks.
* @param {HTMLLinkElement} link - The link element. * @param {HTMLLinkElement} link - The link element.
* @param {ExternalLinkParameters} params - An object with the properties. * @param {ExternalLinkParameters} params
*/ */
function addLinkAttributes(link, params) { function addLinkAttributes(link, params) {
var url = params && params.url; var url = params && params.url;
@ -19792,7 +19792,7 @@ function addLinkAttributes(link, params) {
target = getDefaultSetting('externalLinkTarget'); target = getDefaultSetting('externalLinkTarget');
} }
link.target = LinkTargetStringMap[target]; link.target = LinkTargetStringMap[target];
// Strip referrer from the URL.
var rel = params.rel; var rel = params.rel;
if (typeof rel === 'undefined') { if (typeof rel === 'undefined') {
rel = getDefaultSetting('externalLinkRel'); rel = getDefaultSetting('externalLinkRel');
@ -24052,6 +24052,7 @@ var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationType = sharedUtil.AnnotationType; var AnnotationType = sharedUtil.AnnotationType;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
var addLinkAttributes = displayDOMUtils.addLinkAttributes; var addLinkAttributes = displayDOMUtils.addLinkAttributes;
var LinkTarget = displayDOMUtils.LinkTarget;
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
var warn = sharedUtil.warn; var warn = sharedUtil.warn;
var CustomStyle = displayDOMUtils.CustomStyle; var CustomStyle = displayDOMUtils.CustomStyle;
@ -24299,13 +24300,16 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
this.container.className = 'linkAnnotation'; this.container.className = 'linkAnnotation';
var link = document.createElement('a'); var link = document.createElement('a');
addLinkAttributes(link, { url: this.data.url }); addLinkAttributes(link, {
url: this.data.url,
target: (this.data.newWindow ? LinkTarget.BLANK : undefined),
});
if (!this.data.url) { if (!this.data.url) {
if (this.data.action) { if (this.data.action) {
this._bindNamedAction(link, this.data.action); this._bindNamedAction(link, this.data.action);
} else { } else {
this._bindLink(link, ('dest' in this.data) ? this.data.dest : null); this._bindLink(link, (this.data.dest || null));
} }
} }
@ -48322,6 +48326,8 @@ var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationType = sharedUtil.AnnotationType; var AnnotationType = sharedUtil.AnnotationType;
var OPS = sharedUtil.OPS; var OPS = sharedUtil.OPS;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
var isBool = sharedUtil.isBool;
var isString = sharedUtil.isString;
var isArray = sharedUtil.isArray; var isArray = sharedUtil.isArray;
var isInt = sharedUtil.isInt; var isInt = sharedUtil.isInt;
var isValidUrl = sharedUtil.isValidUrl; var isValidUrl = sharedUtil.isValidUrl;
@ -48990,68 +48996,93 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
var data = this.data; var data = this.data;
data.annotationType = AnnotationType.LINK; data.annotationType = AnnotationType.LINK;
var action = dict.get('A'); var action = dict.get('A'), url, dest;
if (action && isDict(action)) { if (action && isDict(action)) {
var linkType = action.get('S').name; var linkType = action.get('S').name;
if (linkType === 'URI') { switch (linkType) {
var url = action.get('URI'); case 'URI':
if (isName(url)) { url = action.get('URI');
// Some bad PDFs do not put parentheses around relative URLs. if (isName(url)) {
url = '/' + url.name; // Some bad PDFs do not put parentheses around relative URLs.
} else if (url) { url = '/' + url.name;
url = addDefaultProtocolToUrl(url); } else if (url) {
} url = addDefaultProtocolToUrl(url);
// TODO: pdf spec mentions urls can be relative to a Base }
// entry in the dictionary. // TODO: pdf spec mentions urls can be relative to a Base
if (!isValidUrl(url, false)) { // entry in the dictionary.
url = ''; break;
}
// According to ISO 32000-1:2008, section 12.6.4.7, case 'GoTo':
// URI should to be encoded in 7-bit ASCII. dest = action.get('D');
// Some bad PDFs may have URIs in UTF-8 encoding, see Bugzilla 1122280. break;
try {
data.url = stringToUTF8String(url); case 'GoToR':
} catch (e) { var urlDict = action.get('F');
// Fall back to a simple copy. if (isDict(urlDict)) {
data.url = url; // We assume that we found a FileSpec dictionary
} // and fetch the URL without checking any further.
} else if (linkType === 'GoTo') { url = urlDict.get('F') || null;
data.dest = action.get('D'); } else if (isString(urlDict)) {
} else if (linkType === 'GoToR') { url = urlDict;
var urlDict = action.get('F'); }
if (isDict(urlDict)) {
// We assume that the 'url' is a Filspec dictionary // NOTE: the destination is relative to the *remote* document.
// and fetch the url without checking any further var remoteDest = action.get('D');
url = urlDict.get('F') || ''; if (remoteDest) {
} if (isName(remoteDest)) {
remoteDest = remoteDest.name;
// TODO: pdf reference says that GoToR }
// can also have 'NewWindow' attribute if (isString(remoteDest) && isString(url)) {
if (!isValidUrl(url, false)) { var baseUrl = url.split('#')[0];
url = ''; url = baseUrl + '#' + remoteDest;
} }
data.url = url; }
data.dest = action.get('D'); // The 'NewWindow' property, equal to `LinkTarget.BLANK`.
} else if (linkType === 'Named') { var newWindow = action.get('NewWindow');
data.action = action.get('N').name; if (isBool(newWindow)) {
} else { data.newWindow = newWindow;
warn('unrecognized link type: ' + linkType); }
break;
case 'Named':
data.action = action.get('N').name;
break;
default:
warn('unrecognized link type: ' + linkType);
}
} else if (dict.has('Dest')) { // Simple destination link.
dest = dict.get('Dest');
}
if (url) {
if (isValidUrl(url, /* allowRelative = */ false)) {
data.url = tryConvertUrlEncoding(url);
} }
} else if (dict.has('Dest')) { }
// simple destination link if (dest) {
var dest = dict.get('Dest');
data.dest = isName(dest) ? dest.name : dest; data.dest = isName(dest) ? dest.name : dest;
} }
} }
// Lets URLs beginning with 'www.' default to using the 'http://' protocol. // Lets URLs beginning with 'www.' default to using the 'http://' protocol.
function addDefaultProtocolToUrl(url) { function addDefaultProtocolToUrl(url) {
if (url && url.indexOf('www.') === 0) { if (isString(url) && url.indexOf('www.') === 0) {
return ('http://' + url); return ('http://' + url);
} }
return url; return url;
} }
function tryConvertUrlEncoding(url) {
// According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded
// in 7-bit ASCII. Some bad PDFs use UTF-8 encoding, see Bugzilla 1122280.
try {
return stringToUTF8String(url);
} catch (e) {
return url;
}
}
Util.inherit(LinkAnnotation, Annotation, {}); Util.inherit(LinkAnnotation, Annotation, {});
return LinkAnnotation; return LinkAnnotation;

24
build/pdf.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.4.244'; var pdfjsVersion = '1.4.248';
var pdfjsBuild = 'ff65c80'; var pdfjsBuild = '452c031';
var pdfjsFilePath = var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ? typeof document !== 'undefined' && document.currentScript ?
@ -333,7 +333,7 @@ function isSameOrigin(baseUrl, otherUrl) {
// Validates if URL is safe and allowed, e.g. to avoid XSS. // Validates if URL is safe and allowed, e.g. to avoid XSS.
function isValidUrl(url, allowRelative) { function isValidUrl(url, allowRelative) {
if (!url) { if (!url || typeof url !== 'string') {
return false; return false;
} }
// RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1) // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
@ -2469,15 +2469,15 @@ var LinkTargetStringMap = [
/** /**
* @typedef ExternalLinkParameters * @typedef ExternalLinkParameters
* @typedef {Object} ExternalLinkParameters * @typedef {Object} ExternalLinkParameters
* @property {string} url * @property {string} url - An absolute URL.
* @property {LinkTarget} target * @property {LinkTarget} target - The link target.
* @property {string} rel * @property {string} rel - The link relationship.
*/ */
/** /**
* Adds various attributes (href, title, target, rel) to hyperlinks. * Adds various attributes (href, title, target, rel) to hyperlinks.
* @param {HTMLLinkElement} link - The link element. * @param {HTMLLinkElement} link - The link element.
* @param {ExternalLinkParameters} params - An object with the properties. * @param {ExternalLinkParameters} params
*/ */
function addLinkAttributes(link, params) { function addLinkAttributes(link, params) {
var url = params && params.url; var url = params && params.url;
@ -2489,7 +2489,7 @@ function addLinkAttributes(link, params) {
target = getDefaultSetting('externalLinkTarget'); target = getDefaultSetting('externalLinkTarget');
} }
link.target = LinkTargetStringMap[target]; link.target = LinkTargetStringMap[target];
// Strip referrer from the URL.
var rel = params.rel; var rel = params.rel;
if (typeof rel === 'undefined') { if (typeof rel === 'undefined') {
rel = getDefaultSetting('externalLinkRel'); rel = getDefaultSetting('externalLinkRel');
@ -4270,6 +4270,7 @@ var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationType = sharedUtil.AnnotationType; var AnnotationType = sharedUtil.AnnotationType;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
var addLinkAttributes = displayDOMUtils.addLinkAttributes; var addLinkAttributes = displayDOMUtils.addLinkAttributes;
var LinkTarget = displayDOMUtils.LinkTarget;
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
var warn = sharedUtil.warn; var warn = sharedUtil.warn;
var CustomStyle = displayDOMUtils.CustomStyle; var CustomStyle = displayDOMUtils.CustomStyle;
@ -4517,13 +4518,16 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
this.container.className = 'linkAnnotation'; this.container.className = 'linkAnnotation';
var link = document.createElement('a'); var link = document.createElement('a');
addLinkAttributes(link, { url: this.data.url }); addLinkAttributes(link, {
url: this.data.url,
target: (this.data.newWindow ? LinkTarget.BLANK : undefined),
});
if (!this.data.url) { if (!this.data.url) {
if (this.data.action) { if (this.data.action) {
this._bindNamedAction(link, this.data.action); this._bindNamedAction(link, this.data.action);
} else { } else {
this._bindLink(link, ('dest' in this.data) ? this.data.dest : null); this._bindLink(link, (this.data.dest || null));
} }
} }

129
build/pdf.worker.js vendored

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.4.244'; var pdfjsVersion = '1.4.248';
var pdfjsBuild = 'ff65c80'; var pdfjsBuild = '452c031';
var pdfjsFilePath = var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ? typeof document !== 'undefined' && document.currentScript ?
@ -2354,7 +2354,7 @@ function isSameOrigin(baseUrl, otherUrl) {
// Validates if URL is safe and allowed, e.g. to avoid XSS. // Validates if URL is safe and allowed, e.g. to avoid XSS.
function isValidUrl(url, allowRelative) { function isValidUrl(url, allowRelative) {
if (!url) { if (!url || typeof url !== 'string') {
return false; return false;
} }
// RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1) // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
@ -39980,6 +39980,8 @@ var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationType = sharedUtil.AnnotationType; var AnnotationType = sharedUtil.AnnotationType;
var OPS = sharedUtil.OPS; var OPS = sharedUtil.OPS;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
var isBool = sharedUtil.isBool;
var isString = sharedUtil.isString;
var isArray = sharedUtil.isArray; var isArray = sharedUtil.isArray;
var isInt = sharedUtil.isInt; var isInt = sharedUtil.isInt;
var isValidUrl = sharedUtil.isValidUrl; var isValidUrl = sharedUtil.isValidUrl;
@ -40648,68 +40650,93 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
var data = this.data; var data = this.data;
data.annotationType = AnnotationType.LINK; data.annotationType = AnnotationType.LINK;
var action = dict.get('A'); var action = dict.get('A'), url, dest;
if (action && isDict(action)) { if (action && isDict(action)) {
var linkType = action.get('S').name; var linkType = action.get('S').name;
if (linkType === 'URI') { switch (linkType) {
var url = action.get('URI'); case 'URI':
if (isName(url)) { url = action.get('URI');
// Some bad PDFs do not put parentheses around relative URLs. if (isName(url)) {
url = '/' + url.name; // Some bad PDFs do not put parentheses around relative URLs.
} else if (url) { url = '/' + url.name;
url = addDefaultProtocolToUrl(url); } else if (url) {
} url = addDefaultProtocolToUrl(url);
// TODO: pdf spec mentions urls can be relative to a Base }
// entry in the dictionary. // TODO: pdf spec mentions urls can be relative to a Base
if (!isValidUrl(url, false)) { // entry in the dictionary.
url = ''; break;
}
// According to ISO 32000-1:2008, section 12.6.4.7, case 'GoTo':
// URI should to be encoded in 7-bit ASCII. dest = action.get('D');
// Some bad PDFs may have URIs in UTF-8 encoding, see Bugzilla 1122280. break;
try {
data.url = stringToUTF8String(url); case 'GoToR':
} catch (e) { var urlDict = action.get('F');
// Fall back to a simple copy. if (isDict(urlDict)) {
data.url = url; // We assume that we found a FileSpec dictionary
} // and fetch the URL without checking any further.
} else if (linkType === 'GoTo') { url = urlDict.get('F') || null;
data.dest = action.get('D'); } else if (isString(urlDict)) {
} else if (linkType === 'GoToR') { url = urlDict;
var urlDict = action.get('F'); }
if (isDict(urlDict)) {
// We assume that the 'url' is a Filspec dictionary // NOTE: the destination is relative to the *remote* document.
// and fetch the url without checking any further var remoteDest = action.get('D');
url = urlDict.get('F') || ''; if (remoteDest) {
} if (isName(remoteDest)) {
remoteDest = remoteDest.name;
// TODO: pdf reference says that GoToR }
// can also have 'NewWindow' attribute if (isString(remoteDest) && isString(url)) {
if (!isValidUrl(url, false)) { var baseUrl = url.split('#')[0];
url = ''; url = baseUrl + '#' + remoteDest;
} }
data.url = url; }
data.dest = action.get('D'); // The 'NewWindow' property, equal to `LinkTarget.BLANK`.
} else if (linkType === 'Named') { var newWindow = action.get('NewWindow');
data.action = action.get('N').name; if (isBool(newWindow)) {
} else { data.newWindow = newWindow;
warn('unrecognized link type: ' + linkType); }
break;
case 'Named':
data.action = action.get('N').name;
break;
default:
warn('unrecognized link type: ' + linkType);
}
} else if (dict.has('Dest')) { // Simple destination link.
dest = dict.get('Dest');
}
if (url) {
if (isValidUrl(url, /* allowRelative = */ false)) {
data.url = tryConvertUrlEncoding(url);
} }
} else if (dict.has('Dest')) { }
// simple destination link if (dest) {
var dest = dict.get('Dest');
data.dest = isName(dest) ? dest.name : dest; data.dest = isName(dest) ? dest.name : dest;
} }
} }
// Lets URLs beginning with 'www.' default to using the 'http://' protocol. // Lets URLs beginning with 'www.' default to using the 'http://' protocol.
function addDefaultProtocolToUrl(url) { function addDefaultProtocolToUrl(url) {
if (url && url.indexOf('www.') === 0) { if (isString(url) && url.indexOf('www.') === 0) {
return ('http://' + url); return ('http://' + url);
} }
return url; return url;
} }
function tryConvertUrlEncoding(url) {
// According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded
// in 7-bit ASCII. Some bad PDFs use UTF-8 encoding, see Bugzilla 1122280.
try {
return stringToUTF8String(url);
} catch (e) {
return url;
}
}
Util.inherit(LinkAnnotation, Annotation, {}); Util.inherit(LinkAnnotation, Annotation, {});
return LinkAnnotation; return LinkAnnotation;

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.4.244", "version": "1.4.248",
"main": "build/pdf.js", "main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [

Loading…
Cancel
Save