From 41cdb3a49b913ef8b96154e39a6b7f0a835104bc Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 22 Sep 2014 16:26:47 -0500 Subject: [PATCH] PDF.js version 1.0.366 --- bower.json | 2 +- build/pdf.combined.js | 122 ++++++++++++++++++++++++------------------ build/pdf.js | 4 +- build/pdf.worker.js | 122 ++++++++++++++++++++++++------------------ package.json | 2 +- 5 files changed, 144 insertions(+), 108 deletions(-) diff --git a/bower.json b/bower.json index b25472bc0..e3e36bc84 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.362", + "version": "1.0.366", "keywords": [ "Mozilla", "pdf", diff --git a/build/pdf.combined.js b/build/pdf.combined.js index ab72ba591..4ce72888e 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.362'; -PDFJS.build = 'a45e103'; +PDFJS.version = '1.0.366'; +PDFJS.build = '834c69a'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -45213,7 +45213,7 @@ var JpxImage = (function JpxImageClosure() { lbox = length - position + headerSize; } if (lbox < headerSize) { - error('JPX error: Invalid box field size'); + throw new Error('JPX Error: Invalid box field size'); } var dataLength = lbox - headerSize; var jumpDataLength = true; @@ -45237,41 +45237,34 @@ var JpxImage = (function JpxImageClosure() { } }, parseImageProperties: function JpxImage_parseImageProperties(stream) { - try { - var newByte = stream.getByte(); - while (newByte >= 0) { - var oldByte = newByte; - newByte = stream.getByte(); - var code = (oldByte << 8) | newByte; - // Image and tile size (SIZ) - if (code == 0xFF51) { - stream.skip(4); - var Xsiz = stream.getInt32() >>> 0; // Byte 4 - var Ysiz = stream.getInt32() >>> 0; // Byte 8 - var XOsiz = stream.getInt32() >>> 0; // Byte 12 - var YOsiz = stream.getInt32() >>> 0; // Byte 16 - stream.skip(16); - var Csiz = stream.getUint16(); // Byte 36 - this.width = Xsiz - XOsiz; - this.height = Ysiz - YOsiz; - this.componentsCount = Csiz; - // Results are always returned as Uint8Arrays - this.bitsPerComponent = 8; - return; - } - } - throw 'No size marker found in JPX stream'; - } catch (e) { - if (this.failOnCorruptedImage) { - error('JPX error: ' + e); - } else { - warn('JPX error: ' + e + '. Trying to recover'); + var newByte = stream.getByte(); + while (newByte >= 0) { + var oldByte = newByte; + newByte = stream.getByte(); + var code = (oldByte << 8) | newByte; + // Image and tile size (SIZ) + if (code == 0xFF51) { + stream.skip(4); + var Xsiz = stream.getInt32() >>> 0; // Byte 4 + var Ysiz = stream.getInt32() >>> 0; // Byte 8 + var XOsiz = stream.getInt32() >>> 0; // Byte 12 + var YOsiz = stream.getInt32() >>> 0; // Byte 16 + stream.skip(16); + var Csiz = stream.getUint16(); // Byte 36 + this.width = Xsiz - XOsiz; + this.height = Ysiz - YOsiz; + this.componentsCount = Csiz; + // Results are always returned as Uint8Arrays + this.bitsPerComponent = 8; + return; } } + throw new Error('JPX Error: No size marker found in JPX stream'); }, parseCodestream: function JpxImage_parseCodestream(data, start, end) { var context = {}; try { + var doNotRecover = false; var position = start; while (position + 1 < end) { var code = readUint16(data, position); @@ -45315,6 +45308,11 @@ var JpxImage = (function JpxImageClosure() { context.QCC = []; context.COC = []; break; + case 0xFF55: // Tile-part lengths, main header (TLM) + var Ltlm = readUint16(data, position); // Marker segment length + // Skip tile length markers + position += Ltlm; + break; case 0xFF5C: // Quantization default (QCD) length = readUint16(data, position); var qcd = {}; @@ -45334,7 +45332,7 @@ var JpxImage = (function JpxImageClosure() { scalarExpounded = true; break; default: - throw 'Invalid SQcd value ' + sqcd; + throw new Error('JPX Error: Invalid SQcd value ' + sqcd); } qcd.noQuantization = (spqcdSize == 8); qcd.scalarExpounded = scalarExpounded; @@ -45386,7 +45384,7 @@ var JpxImage = (function JpxImageClosure() { scalarExpounded = true; break; default: - throw 'Invalid SQcd value ' + sqcd; + throw new Error('JPX Error: Invalid SQcd value ' + sqcd); } qcc.noQuantization = (spqcdSize == 8); qcc.scalarExpounded = scalarExpounded; @@ -45446,16 +45444,33 @@ var JpxImage = (function JpxImageClosure() { } cod.precinctsSizes = precinctsSizes; } - - if (cod.sopMarkerUsed || cod.ephMarkerUsed || - cod.selectiveArithmeticCodingBypass || - cod.resetContextProbabilities || - cod.terminationOnEachCodingPass || - cod.verticalyStripe || cod.predictableTermination) { - throw 'Unsupported COD options: ' + - globalScope.JSON.stringify(cod); + var unsupported = []; + if (cod.sopMarkerUsed) { + unsupported.push('sopMarkerUsed'); + } + if (cod.ephMarkerUsed) { + unsupported.push('ephMarkerUsed'); + } + if (cod.selectiveArithmeticCodingBypass) { + unsupported.push('selectiveArithmeticCodingBypass'); + } + if (cod.resetContextProbabilities) { + unsupported.push('resetContextProbabilities'); + } + if (cod.terminationOnEachCodingPass) { + unsupported.push('terminationOnEachCodingPass'); + } + if (cod.verticalyStripe) { + unsupported.push('verticalyStripe'); + } + if (cod.predictableTermination) { + unsupported.push('predictableTermination'); + } + if (unsupported.length > 0) { + doNotRecover = true; + throw new Error('JPX Error: Unsupported COD options (' + + unsupported.join(', ') + ')'); } - if (context.mainHeader) { context.COD = cod; } else { @@ -45498,17 +45513,19 @@ var JpxImage = (function JpxImageClosure() { // skipping content break; case 0xFF53: // Coding style component (COC) - throw 'Codestream code 0xFF53 (COC) is not implemented'; + throw new Error('JPX Error: Codestream code 0xFF53 (COC) is ' + + 'not implemented'); default: - throw 'Unknown codestream code: ' + code.toString(16); + throw new Error('JPX Error: Unknown codestream code: ' + + code.toString(16)); } position += length; } } catch (e) { - if (this.failOnCorruptedImage) { - error('JPX error: ' + e); + if (doNotRecover || this.failOnCorruptedImage) { + throw e; } else { - warn('JPX error: ' + e + '. Trying to recover'); + warn('Trying to recover from ' + e.message); } } this.tiles = transformComponents(context); @@ -45736,7 +45753,7 @@ var JpxImage = (function JpxImageClosure() { } r = 0; } - throw 'Out of packets'; + throw new Error('JPX Error: Out of packets'); }; } function ResolutionLayerComponentPositionIterator(context) { @@ -45776,7 +45793,7 @@ var JpxImage = (function JpxImageClosure() { } l = 0; } - throw 'Out of packets'; + throw new Error('JPX Error: Out of packets'); }; } function buildPackets(context) { @@ -45871,7 +45888,8 @@ var JpxImage = (function JpxImageClosure() { new ResolutionLayerComponentPositionIterator(context); break; default: - throw 'Unsupported progression order ' + progressionOrder; + throw new Error('JPX Error: Unsupported progression order ' + + progressionOrder); } } function parseTilePackets(context, data, offset, dataLength) { @@ -46784,7 +46802,7 @@ var JpxImage = (function JpxImageClosure() { (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) | decoder.readBit(contexts, UNIFORM_CONTEXT); if (symbol != 0xA) { - throw 'Invalid segmentation symbol'; + throw new Error('JPX Error: Invalid segmentation symbol'); } } }; diff --git a/build/pdf.js b/build/pdf.js index b1036581d..eeabbcd78 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.362'; -PDFJS.build = 'a45e103'; +PDFJS.version = '1.0.366'; +PDFJS.build = '834c69a'; (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 3f04b6bd2..906c622c6 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.362'; -PDFJS.build = 'a45e103'; +PDFJS.version = '1.0.366'; +PDFJS.build = '834c69a'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -40689,7 +40689,7 @@ var JpxImage = (function JpxImageClosure() { lbox = length - position + headerSize; } if (lbox < headerSize) { - error('JPX error: Invalid box field size'); + throw new Error('JPX Error: Invalid box field size'); } var dataLength = lbox - headerSize; var jumpDataLength = true; @@ -40713,41 +40713,34 @@ var JpxImage = (function JpxImageClosure() { } }, parseImageProperties: function JpxImage_parseImageProperties(stream) { - try { - var newByte = stream.getByte(); - while (newByte >= 0) { - var oldByte = newByte; - newByte = stream.getByte(); - var code = (oldByte << 8) | newByte; - // Image and tile size (SIZ) - if (code == 0xFF51) { - stream.skip(4); - var Xsiz = stream.getInt32() >>> 0; // Byte 4 - var Ysiz = stream.getInt32() >>> 0; // Byte 8 - var XOsiz = stream.getInt32() >>> 0; // Byte 12 - var YOsiz = stream.getInt32() >>> 0; // Byte 16 - stream.skip(16); - var Csiz = stream.getUint16(); // Byte 36 - this.width = Xsiz - XOsiz; - this.height = Ysiz - YOsiz; - this.componentsCount = Csiz; - // Results are always returned as Uint8Arrays - this.bitsPerComponent = 8; - return; - } - } - throw 'No size marker found in JPX stream'; - } catch (e) { - if (this.failOnCorruptedImage) { - error('JPX error: ' + e); - } else { - warn('JPX error: ' + e + '. Trying to recover'); + var newByte = stream.getByte(); + while (newByte >= 0) { + var oldByte = newByte; + newByte = stream.getByte(); + var code = (oldByte << 8) | newByte; + // Image and tile size (SIZ) + if (code == 0xFF51) { + stream.skip(4); + var Xsiz = stream.getInt32() >>> 0; // Byte 4 + var Ysiz = stream.getInt32() >>> 0; // Byte 8 + var XOsiz = stream.getInt32() >>> 0; // Byte 12 + var YOsiz = stream.getInt32() >>> 0; // Byte 16 + stream.skip(16); + var Csiz = stream.getUint16(); // Byte 36 + this.width = Xsiz - XOsiz; + this.height = Ysiz - YOsiz; + this.componentsCount = Csiz; + // Results are always returned as Uint8Arrays + this.bitsPerComponent = 8; + return; } } + throw new Error('JPX Error: No size marker found in JPX stream'); }, parseCodestream: function JpxImage_parseCodestream(data, start, end) { var context = {}; try { + var doNotRecover = false; var position = start; while (position + 1 < end) { var code = readUint16(data, position); @@ -40791,6 +40784,11 @@ var JpxImage = (function JpxImageClosure() { context.QCC = []; context.COC = []; break; + case 0xFF55: // Tile-part lengths, main header (TLM) + var Ltlm = readUint16(data, position); // Marker segment length + // Skip tile length markers + position += Ltlm; + break; case 0xFF5C: // Quantization default (QCD) length = readUint16(data, position); var qcd = {}; @@ -40810,7 +40808,7 @@ var JpxImage = (function JpxImageClosure() { scalarExpounded = true; break; default: - throw 'Invalid SQcd value ' + sqcd; + throw new Error('JPX Error: Invalid SQcd value ' + sqcd); } qcd.noQuantization = (spqcdSize == 8); qcd.scalarExpounded = scalarExpounded; @@ -40862,7 +40860,7 @@ var JpxImage = (function JpxImageClosure() { scalarExpounded = true; break; default: - throw 'Invalid SQcd value ' + sqcd; + throw new Error('JPX Error: Invalid SQcd value ' + sqcd); } qcc.noQuantization = (spqcdSize == 8); qcc.scalarExpounded = scalarExpounded; @@ -40922,16 +40920,33 @@ var JpxImage = (function JpxImageClosure() { } cod.precinctsSizes = precinctsSizes; } - - if (cod.sopMarkerUsed || cod.ephMarkerUsed || - cod.selectiveArithmeticCodingBypass || - cod.resetContextProbabilities || - cod.terminationOnEachCodingPass || - cod.verticalyStripe || cod.predictableTermination) { - throw 'Unsupported COD options: ' + - globalScope.JSON.stringify(cod); + var unsupported = []; + if (cod.sopMarkerUsed) { + unsupported.push('sopMarkerUsed'); + } + if (cod.ephMarkerUsed) { + unsupported.push('ephMarkerUsed'); + } + if (cod.selectiveArithmeticCodingBypass) { + unsupported.push('selectiveArithmeticCodingBypass'); + } + if (cod.resetContextProbabilities) { + unsupported.push('resetContextProbabilities'); + } + if (cod.terminationOnEachCodingPass) { + unsupported.push('terminationOnEachCodingPass'); + } + if (cod.verticalyStripe) { + unsupported.push('verticalyStripe'); + } + if (cod.predictableTermination) { + unsupported.push('predictableTermination'); + } + if (unsupported.length > 0) { + doNotRecover = true; + throw new Error('JPX Error: Unsupported COD options (' + + unsupported.join(', ') + ')'); } - if (context.mainHeader) { context.COD = cod; } else { @@ -40974,17 +40989,19 @@ var JpxImage = (function JpxImageClosure() { // skipping content break; case 0xFF53: // Coding style component (COC) - throw 'Codestream code 0xFF53 (COC) is not implemented'; + throw new Error('JPX Error: Codestream code 0xFF53 (COC) is ' + + 'not implemented'); default: - throw 'Unknown codestream code: ' + code.toString(16); + throw new Error('JPX Error: Unknown codestream code: ' + + code.toString(16)); } position += length; } } catch (e) { - if (this.failOnCorruptedImage) { - error('JPX error: ' + e); + if (doNotRecover || this.failOnCorruptedImage) { + throw e; } else { - warn('JPX error: ' + e + '. Trying to recover'); + warn('Trying to recover from ' + e.message); } } this.tiles = transformComponents(context); @@ -41212,7 +41229,7 @@ var JpxImage = (function JpxImageClosure() { } r = 0; } - throw 'Out of packets'; + throw new Error('JPX Error: Out of packets'); }; } function ResolutionLayerComponentPositionIterator(context) { @@ -41252,7 +41269,7 @@ var JpxImage = (function JpxImageClosure() { } l = 0; } - throw 'Out of packets'; + throw new Error('JPX Error: Out of packets'); }; } function buildPackets(context) { @@ -41347,7 +41364,8 @@ var JpxImage = (function JpxImageClosure() { new ResolutionLayerComponentPositionIterator(context); break; default: - throw 'Unsupported progression order ' + progressionOrder; + throw new Error('JPX Error: Unsupported progression order ' + + progressionOrder); } } function parseTilePackets(context, data, offset, dataLength) { @@ -42260,7 +42278,7 @@ var JpxImage = (function JpxImageClosure() { (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) | decoder.readBit(contexts, UNIFORM_CONTEXT); if (symbol != 0xA) { - throw 'Invalid segmentation symbol'; + throw new Error('JPX Error: Invalid segmentation symbol'); } } }; diff --git a/package.json b/package.json index c8273dcfa..36aa875a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.362", + "version": "1.0.366", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",