[Pkg-javascript-commits] [pdf.js] 33/174: Make `XRef_indexObjects` even more robust against bad PDF files, by checking for the existence of 'trailer' if 'xref' is not found

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:05 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 192907e0d29ed72dd8f5322692ad39afb64fb909
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Oct 1 14:46:03 2015 +0200

    Make `XRef_indexObjects` even more robust against bad PDF files, by checking for the existence of 'trailer' if 'xref' is not found
    
    Fixes http://www.cyjack.com/cognition/Terence%20McKenna%20-%20Lectures%20on%20Alchemy.pdf.
---
 src/core/obj.js                    |  4 +++
 test/pdfs/.gitignore               |  1 +
 test/pdfs/xref_command_missing.pdf | 66 ++++++++++++++++++++++++++++++++++++++
 test/test_manifest.json            |  7 ++++
 4 files changed, 78 insertions(+)

diff --git a/src/core/obj.js b/src/core/obj.js
index be62eab..204fd3f 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -1118,6 +1118,10 @@ var XRef = (function XRefClosure() {
           }
 
           position += contentLength;
+        } else if (token.indexOf('trailer') === 0 &&
+                   (token.length === 7 || /\s/.test(token[7]))) {
+          trailers.push(position);
+          position += skipUntil(buffer, position, startxrefBytes);
         } else {
           position += token.length + 1;
         }
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index de2d8b7..29199df 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -4,6 +4,7 @@
 !tracemonkey.pdf
 !franz.pdf
 !franz_2.pdf
+!xref_command_missing.pdf
 !issue2391-1.pdf
 !issue2391-2.pdf
 !issue5801.pdf
diff --git a/test/pdfs/xref_command_missing.pdf b/test/pdfs/xref_command_missing.pdf
new file mode 100644
index 0000000..2795a14
--- /dev/null
+++ b/test/pdfs/xref_command_missing.pdf
@@ -0,0 +1,66 @@
+%PDF-1.7
+%����
+1 0 obj 
+<<
+/Pages 2 0 R
+/Type /Catalog
+>>
+endobj 
+2 0 obj 
+<<
+/Kids [3 0 R]
+/Type /Pages
+/Count 1
+>>
+endobj 
+3 0 obj 
+<<
+/Parent 2 0 R
+/Resources 
+<<
+/Font 
+<<
+/F1 4 0 R
+>>
+>>
+/MediaBox [0 0 200 50]
+/Type /Page
+/Contents 5 0 R
+>>
+endobj 
+4 0 obj 
+<<
+/BaseFont /Times-Roman
+/Subtype /Type1
+/Type /Font
+/Encoding /WinAnsiEncoding
+>>
+endobj 
+5 0 obj 
+<<
+/Length 48
+>>
+stream
+BT
+10 20 TD
+/F1 20 Tf
+(Reduced test-case) Tj
+ET
+
+endstream 
+endobj 
+0000000000 65535 f 
+0000000015 00000 n 
+0000000066 00000 n 
+0000000125 00000 n 
+0000000254 00000 n 
+0000000355 00000 n 
+trailer
+
+<<
+/Root 1 0 R
+/Size 6
+>>
+startxref
+455
+%%EOF
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 834e431..12ebb9b 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -572,6 +572,13 @@
        "link": false,
        "type": "eq"
     },
+    {  "id": "xref_command_missing",
+       "file": "pdfs/xref_command_missing.pdf",
+       "md5": "06cdb0f13cfeff41d6bfb24b7bbe1268",
+       "rounds": 1,
+       "link": false,
+       "type": "load"
+    },
     {  "id": "issue5501",
        "file": "pdfs/issue5501.pdf",
        "md5": "55a60699728fc92f491a2d7d490474e4",

-- 
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