[Pkg-javascript-commits] [pdf.js] 128/139: Ensure that |get fingerprint| doesn't fail if the ID is not an array (issue 5599)

David Prévot taffit at moszumanska.debian.org
Fri Jan 9 21:18:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 1fea44ce1493000a8e6932b1685d93c71eb5d0ba
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Dec 30 15:43:04 2014 +0100

    Ensure that |get fingerprint| doesn't fail if the ID is not an array (issue 5599)
    
    According to the [PDF specification](http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=51) the `ID` should be an array. To prevent errors if the PDF file violates that part of the spec, check that the `ID` is actually an array.
    
    Fixes 5599.
---
 src/core/core.js        | 12 ++++----
 test/pdfs/.gitignore    |  1 +
 test/pdfs/issue5599.pdf | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/test_manifest.json |  7 +++++
 4 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/src/core/core.js b/src/core/core.js
index 14ceddd..0e0fa27 100644
--- a/src/core/core.js
+++ b/src/core/core.js
@@ -281,9 +281,9 @@ var Page = (function PageClosure() {
  */
 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);
@@ -495,11 +495,13 @@ var PDFDocument = (function PDFDocumentClosure() {
       return shadow(this, 'documentInfo', docInfo);
     },
     get fingerprint() {
-      var xref = this.xref, hash, fileID = '';
+      var xref = this.xref, idArray, hash, fileID = '';
 
-      if (xref.trailer.has('ID') &&
-          xref.trailer.get('ID')[0] !== EMPTY_FINGERPRINT) {
-        hash = stringToBytes(xref.trailer.get('ID')[0]);
+      if (xref.trailer.has('ID')) {
+        idArray = xref.trailer.get('ID');
+      }
+      if (idArray && isArray(idArray) && idArray[0] !== EMPTY_FINGERPRINT) {
+        hash = stringToBytes(idArray[0]);
       } else {
         if (this.stream.ensureRange) {
           this.stream.ensureRange(0,
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 4bdc7c7..e612c39 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -70,6 +70,7 @@
 !issue5291.pdf
 !issue5421.pdf
 !issue5470.pdf
+!issue5599.pdf
 !gradientfill.pdf
 !bug903856.pdf
 !bug850854.pdf
diff --git a/test/pdfs/issue5599.pdf b/test/pdfs/issue5599.pdf
new file mode 100644
index 0000000..50517b2
--- /dev/null
+++ b/test/pdfs/issue5599.pdf
@@ -0,0 +1,76 @@
+%PDF-1.7
+%����
+1 0 obj 
+<<
+/Type /Encoding
+/BaseEncoding /WinAnsiEncoding
+>>
+endobj 
+2 0 obj 
+<<
+/Pages 3 0 R
+/Type /Catalog
+>>
+endobj 
+3 0 obj 
+<<
+/MediaBox [0 0 200 50]
+/Kids [4 0 R]
+/Count 1
+/Type /Pages
+>>
+endobj 
+4 0 obj 
+<<
+/Parent 3 0 R
+/MediaBox [0 0 200 50]
+/Resources 
+<<
+/Font 
+<<
+/F1 5 0 R
+>>
+>>
+/Contents 6 0 R
+/Type /Page
+>>
+endobj 
+5 0 obj 
+<<
+/BaseFont /Times-Roman
+/Subtype /Type1
+/Encoding 1 0 R
+/Type /Font
+>>
+endobj 
+6 0 obj 
+<<
+/Length 41
+>>
+stream
+BT
+10 20 TD
+/F1 20 Tf
+(Issue 5599) Tj
+ET
+
+endstream 
+endobj xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000085 00000 n 
+0000000136 00000 n 
+0000000218 00000 n 
+0000000347 00000 n 
+0000000437 00000 n 
+trailer
+
+<<
+/Root 2 0 R
+/Size 7
+/ID 77777777777777777
+>>
+startxref
+530
+%%EOF
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 303a4d7..1e05ff5 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -508,6 +508,13 @@
        "lastPage": 1,
        "type": "load"
     },
+    {  "id": "issue5599",
+       "file": "pdfs/issue5599.pdf",
+       "md5": "529a4a9409ac024aeb57a047210280fe",
+       "rounds": 1,
+       "link": false,
+       "type": "load"
+    },
     {  "id": "txt2pdf",
        "file": "pdfs/txt2pdf.pdf",
        "md5": "02cefa0f5e8d96313bb05163b2f88c8c",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list