[Pkg-javascript-commits] [pdf.js] 143/174: Prevent `readCmapTable` from failing if the `cmap` is missing in TrueType fonts

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45: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 ff64ef0243e57b18a73368e8132bd214a28ca378
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sun Nov 8 13:18:23 2015 +0100

    Prevent `readCmapTable` from failing if the `cmap` is missing in TrueType fonts
    
    Fixes http://arrow.dit.ie/cgi/viewcontent.cgi?article=1000&context=aaschadpoth#page=3.
---
 src/core/fonts.js                   |   9 +++++++++
 test/pdfs/.gitignore                |   1 +
 test/pdfs/TrueType_without_cmap.pdf | Bin 0 -> 3989 bytes
 test/test_manifest.json             |   7 +++++++
 4 files changed, 17 insertions(+)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index cd9c34f..b04fbdc 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -3226,6 +3226,15 @@ var Font = (function FontClosure() {
        * PDF spec
        */
       function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
+        if (!cmap) {
+          warn('No cmap table available.');
+          return {
+            platformId: -1,
+            encodingId: -1,
+            mappings: [],
+            hasShortCmap: false
+          };
+        }
         var segment;
         var start = (font.start ? font.start : 0) + cmap.offset;
         font.pos = start;
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 7bad8e6..cd4ec02 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -2,6 +2,7 @@
 *.error
 
 !tracemonkey.pdf
+!TrueType_without_cmap.pdf
 !franz.pdf
 !franz_2.pdf
 !xref_command_missing.pdf
diff --git a/test/pdfs/TrueType_without_cmap.pdf b/test/pdfs/TrueType_without_cmap.pdf
new file mode 100644
index 0000000..0cfad2d
Binary files /dev/null and b/test/pdfs/TrueType_without_cmap.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 825b5c8..c40cfcd 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1196,6 +1196,13 @@
        "rounds": 1,
        "type": "eq"
     },
+    {  "id": "TrueType_without_cmap",
+       "file": "pdfs/TrueType_without_cmap.pdf",
+       "md5": "afca8bb11f2e1f7298b4e5dd85785fb0",
+       "link": false,
+       "rounds": 1,
+       "type": "eq"
+    },
     {  "id": "issue3323",
        "file": "pdfs/issue3323.pdf",
        "md5": "1a14ff574013caeafa9d598269988764",

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