[Pkg-javascript-commits] [pdf.js] 10/246: Fix loading of PDF files with invalid or missing Type3 characters (issue 5039)

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:20 UTC 2014


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

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

commit 2485f11829db012c6e939d53fe4634304ebb1db0
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Jul 24 14:59:21 2014 +0200

    Fix loading of PDF files with invalid or missing Type3 characters (issue 5039)
---
 src/core/evaluator.js   |  19 +++++++++++--------
 src/display/canvas.js   |   7 ++++++-
 test/pdfs/.gitignore    |   1 +
 test/pdfs/issue5039.pdf | Bin 0 -> 30475 bytes
 test/test_manifest.json |   7 +++++++
 5 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index 2579ddf..279c476 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -1760,14 +1760,17 @@ var TranslatedFont = (function TranslatedFontClosure() {
           var glyphStream = charProcs[key];
           var operatorList = new OperatorList();
           return evaluator.getOperatorList(glyphStream, fontResources,
-            operatorList).
-            then(function () {
-              charProcOperatorList[key] = operatorList.getIR();
-
-              // Add the dependencies to the parent operator list so they are
-              // resolved before sub operator list is executed synchronously.
-              parentOperatorList.addDependencies(operatorList.dependencies);
-            });
+                                           operatorList).then(function () {
+            charProcOperatorList[key] = operatorList.getIR();
+
+            // Add the dependencies to the parent operator list so they are
+            // resolved before sub operator list is executed synchronously.
+            parentOperatorList.addDependencies(operatorList.dependencies);
+          }, function (reason) {
+            warn('Type3 font resource \"' + key + '\" is not available');
+            var operatorList = new OperatorList();
+            charProcOperatorList[key] = operatorList.getIR();
+          });
         }.bind(this, charProcKeys[i]));
       }
       this.type3Loaded = loadCharProcsPromise.then(function () {
diff --git a/src/display/canvas.js b/src/display/canvas.js
index fab6687..9972a8a 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -1489,11 +1489,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
           continue;
         }
 
+        var operatorList = font.charProcOperatorList[glyph.operatorListId];
+        if (!operatorList) {
+          warn('Type3 character \"' + glyph.operatorListId +
+               '\" is not available');
+          continue;
+        }
         this.processingType3 = glyph;
         this.save();
         ctx.scale(fontSize, fontSize);
         ctx.transform.apply(ctx, fontMatrix);
-        var operatorList = font.charProcOperatorList[glyph.operatorListId];
         this.executeOperatorList(operatorList);
         this.restore();
 
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index ad85981..51bc02b 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -52,6 +52,7 @@
 !issue1002.pdf
 !issue925.pdf
 !issue4668.pdf
+!issue5039.pdf
 !gradientfill.pdf
 !bug903856.pdf
 !bug850854.pdf
diff --git a/test/pdfs/issue5039.pdf b/test/pdfs/issue5039.pdf
new file mode 100644
index 0000000..dfe29fe
Binary files /dev/null and b/test/pdfs/issue5039.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index cc2ce05..313a4ab 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1024,6 +1024,13 @@
       "link": true,
       "type": "eq"
     },
+    {  "id": "issue5039",
+       "file": "pdfs/issue5039.pdf",
+       "md5": "5c131f458ee6b65cc096ccaf0474ee3a",
+       "link": false,
+       "rounds": 1,
+       "type": "eq"
+    },
     {  "id": "issue1257",
       "file": "pdfs/issue1257.pdf",
       "md5": "9111533826bc21ed774e8e01603a2f54",

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