From 259a5c7df5e3d7acc74432a8f652ba88dafabf8a Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Tue, 29 Dec 2015 21:37:20 +0000 Subject: [PATCH] PDF.js version 1.3.137 - See mozilla/pdf.js@b8e7efaaa11a04d370ddd8860b73f8b87253a858 --- bower.json | 2 +- build/pdf.combined.js | 27 ++++++++++++++++++++++++--- build/pdf.js | 4 ++-- build/pdf.worker.js | 27 ++++++++++++++++++++++++--- package.json | 2 +- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/bower.json b/bower.json index c3aa08151..97ae328e1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.3.135", + "version": "1.3.137", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index f2ab82b02..188b015fe 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { typeof global !== 'undefined' ? global : this).PDFJS = {}; } -PDFJS.version = '1.3.135'; -PDFJS.build = 'b32cdf5'; +PDFJS.version = '1.3.137'; +PDFJS.build = 'b8e7efa'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -25684,6 +25684,7 @@ var utf8StringToString = sharedUtil.utf8StringToString; var warn = sharedUtil.warn; var Name = corePrimitives.Name; var isName = corePrimitives.isName; +var isDict = corePrimitives.isDict; var DecryptStream = coreStream.DecryptStream; var ARCFourCipher = (function ARCFourCipherClosure() { @@ -27567,7 +27568,27 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { error('unsupported encryption algorithm'); } this.algorithm = algorithm; - var keyLength = dict.get('Length') || 40; + var keyLength = dict.get('Length'); + if (!keyLength) { + // Spec asks to rely on encryption dictionary's Length entry, however + // some PDFs don't have it. Trying to recover. + if (algorithm <= 3) { + // For 1 and 2 it's fixed to 40-bit, for 3 40-bit is a minimal value. + keyLength = 40; + } else { + // Trying to find default handler -- it usually has Length. + var cfDict = dict.get('CF'); + var streamCryptoName = dict.get('StmF'); + if (isDict(cfDict) && isName(streamCryptoName)) { + var handlerDict = cfDict.get(streamCryptoName.name); + keyLength = (handlerDict && handlerDict.get('Length')) || 128; + if (keyLength < 40) { + // Sometimes it's incorrect value of bits, generators specify bytes. + keyLength <<= 3; + } + } + } + } if (!isInt(keyLength) || keyLength < 40 || (keyLength % 8) !== 0) { error('invalid key length'); diff --git a/build/pdf.js b/build/pdf.js index 1b0fc734b..2c96e3f4e 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { typeof global !== 'undefined' ? global : this).PDFJS = {}; } -PDFJS.version = '1.3.135'; -PDFJS.build = 'b32cdf5'; +PDFJS.version = '1.3.137'; +PDFJS.build = 'b8e7efa'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index d34ae13a0..572062a99 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { typeof global !== 'undefined' ? global : this).PDFJS = {}; } -PDFJS.version = '1.3.135'; -PDFJS.build = 'b32cdf5'; +PDFJS.version = '1.3.137'; +PDFJS.build = 'b8e7efa'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -17965,6 +17965,7 @@ var utf8StringToString = sharedUtil.utf8StringToString; var warn = sharedUtil.warn; var Name = corePrimitives.Name; var isName = corePrimitives.isName; +var isDict = corePrimitives.isDict; var DecryptStream = coreStream.DecryptStream; var ARCFourCipher = (function ARCFourCipherClosure() { @@ -19848,7 +19849,27 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { error('unsupported encryption algorithm'); } this.algorithm = algorithm; - var keyLength = dict.get('Length') || 40; + var keyLength = dict.get('Length'); + if (!keyLength) { + // Spec asks to rely on encryption dictionary's Length entry, however + // some PDFs don't have it. Trying to recover. + if (algorithm <= 3) { + // For 1 and 2 it's fixed to 40-bit, for 3 40-bit is a minimal value. + keyLength = 40; + } else { + // Trying to find default handler -- it usually has Length. + var cfDict = dict.get('CF'); + var streamCryptoName = dict.get('StmF'); + if (isDict(cfDict) && isName(streamCryptoName)) { + var handlerDict = cfDict.get(streamCryptoName.name); + keyLength = (handlerDict && handlerDict.get('Length')) || 128; + if (keyLength < 40) { + // Sometimes it's incorrect value of bits, generators specify bytes. + keyLength <<= 3; + } + } + } + } if (!isInt(keyLength) || keyLength < 40 || (keyLength % 8) !== 0) { error('invalid key length'); diff --git a/package.json b/package.json index fb9600964..169edd86c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.3.135", + "version": "1.3.137", "main": "build/pdf.js", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [