Browse Source

PDF.js version 1.0.984

Pdf Bot 10 years ago
parent
commit
b00ca56d54
5 changed files with 36 additions and 14 deletions
  1. 1 1
      bower.json
  2. 16 5
      build/pdf.combined.js
  3. 2 2
      build/pdf.js
  4. 16 5
      build/pdf.worker.js
  5. 1 1
      package.json

+ 1 - 1
bower.json

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

+ 16 - 5
build/pdf.combined.js

@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
   (typeof window !== 'undefined' ? window : this).PDFJS = {};
 }
 
-PDFJS.version = '1.0.982';
-PDFJS.build = 'f5df30f';
+PDFJS.version = '1.0.984';
+PDFJS.build = 'ee1b125';
 
 (function pdfjsWrapper() {
   // Use strict in our context only - users might not want it
@@ -8975,6 +8975,10 @@ var Page = (function PageClosure() {
  * `PDFDocument` objects on the main thread created.
  */
 var PDFDocument = (function PDFDocumentClosure() {
+  var FINGERPRINT_FIRST_BYTES = 1024;
+
+  var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' +
+    '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
   function PDFDocument(pdfManager, arg, password) {
     if (isStream(arg)) {
       init.call(this, pdfManager, arg, password);
@@ -9188,14 +9192,21 @@ var PDFDocument = (function PDFDocumentClosure() {
     get fingerprint() {
       var xref = this.xref, hash, fileID = '';
 
-      if (xref.trailer.has('ID')) {
+      if (xref.trailer.has('ID') &&
+          xref.trailer.get('ID')[0] !== EMPTY_FINGERPRINT) {
         hash = stringToBytes(xref.trailer.get('ID')[0]);
       } else {
-        hash = calculateMD5(this.stream.bytes.subarray(0, 100), 0, 100);
+        if (this.stream.ensureRange) {
+          this.stream.ensureRange(0,
+            Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
+        }
+        hash = calculateMD5(this.stream.bytes.subarray(0,
+          FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
       }
 
       for (var i = 0, n = hash.length; i < n; i++) {
-        fileID += hash[i].toString(16);
+        var hex = hash[i].toString(16);
+        fileID += hex.length === 1 ? '0' + hex : hex;
       }
 
       return shadow(this, 'fingerprint', fileID);

+ 2 - 2
build/pdf.js

@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
   (typeof window !== 'undefined' ? window : this).PDFJS = {};
 }
 
-PDFJS.version = '1.0.982';
-PDFJS.build = 'f5df30f';
+PDFJS.version = '1.0.984';
+PDFJS.build = 'ee1b125';
 
 (function pdfjsWrapper() {
   // Use strict in our context only - users might not want it

+ 16 - 5
build/pdf.worker.js

@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
   (typeof window !== 'undefined' ? window : this).PDFJS = {};
 }
 
-PDFJS.version = '1.0.982';
-PDFJS.build = 'f5df30f';
+PDFJS.version = '1.0.984';
+PDFJS.build = 'ee1b125';
 
 (function pdfjsWrapper() {
   // Use strict in our context only - users might not want it
@@ -2848,6 +2848,10 @@ var Page = (function PageClosure() {
  * `PDFDocument` objects on the main thread created.
  */
 var PDFDocument = (function PDFDocumentClosure() {
+  var FINGERPRINT_FIRST_BYTES = 1024;
+
+  var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' +
+    '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
   function PDFDocument(pdfManager, arg, password) {
     if (isStream(arg)) {
       init.call(this, pdfManager, arg, password);
@@ -3061,14 +3065,21 @@ var PDFDocument = (function PDFDocumentClosure() {
     get fingerprint() {
       var xref = this.xref, hash, fileID = '';
 
-      if (xref.trailer.has('ID')) {
+      if (xref.trailer.has('ID') &&
+          xref.trailer.get('ID')[0] !== EMPTY_FINGERPRINT) {
         hash = stringToBytes(xref.trailer.get('ID')[0]);
       } else {
-        hash = calculateMD5(this.stream.bytes.subarray(0, 100), 0, 100);
+        if (this.stream.ensureRange) {
+          this.stream.ensureRange(0,
+            Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
+        }
+        hash = calculateMD5(this.stream.bytes.subarray(0,
+          FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
       }
 
       for (var i = 0, n = hash.length; i < n; i++) {
-        fileID += hash[i].toString(16);
+        var hex = hash[i].toString(16);
+        fileID += hex.length === 1 ? '0' + hex : hex;
       }
 
       return shadow(this, 'fingerprint', fileID);

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.0.982",
+  "version": "1.0.984",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [
     "Mozilla",