[Pkg-javascript-commits] [pdf.js] 70/139: Fallback to the |Dummy| Pattern when we fail to parse a Shading Pattern (issue 5509)

David Prévot taffit at moszumanska.debian.org
Fri Jan 9 21:18:28 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 78d0d269dc6cd55494834bfe79649f2c93a33b8f
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sun Nov 30 21:15:18 2014 +0100

    Fallback to the |Dummy| Pattern when we fail to parse a Shading Pattern (issue 5509)
---
 src/core/pattern.js          | 37 +++++++++++++++++++++++--------------
 test/pdfs/issue5509.pdf.link |  1 +
 test/test_manifest.json      |  9 +++++++++
 3 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/src/core/pattern.js b/src/core/pattern.js
index 2bb9c72..b769f22 100644
--- a/src/core/pattern.js
+++ b/src/core/pattern.js
@@ -15,7 +15,8 @@
  * limitations under the License.
  */
 /* globals ColorSpace, PDFFunction, Util, error, warn, info, isArray, isStream,
-           assert, isPDFFunction, UnsupportedManager, UNSUPPORTED_FEATURES */
+           assert, isPDFFunction, UnsupportedManager, UNSUPPORTED_FEATURES,
+           MissingDataException */
 
 'use strict';
 
@@ -49,19 +50,27 @@ var Pattern = (function PatternClosure() {
     var dict = isStream(shading) ? shading.dict : shading;
     var type = dict.get('ShadingType');
 
-    switch (type) {
-      case PatternType.AXIAL:
-      case PatternType.RADIAL:
-        // Both radial and axial shadings are handled by RadialAxial shading.
-        return new Shadings.RadialAxial(dict, matrix, xref, res);
-      case PatternType.FREE_FORM_MESH:
-      case PatternType.LATTICE_FORM_MESH:
-      case PatternType.COONS_PATCH_MESH:
-      case PatternType.TENSOR_PATCH_MESH:
-        return new Shadings.Mesh(shading, matrix, xref, res);
-      default:
-        UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
-        return new Shadings.Dummy();
+    try {
+      switch (type) {
+        case PatternType.AXIAL:
+        case PatternType.RADIAL:
+          // Both radial and axial shadings are handled by RadialAxial shading.
+          return new Shadings.RadialAxial(dict, matrix, xref, res);
+        case PatternType.FREE_FORM_MESH:
+        case PatternType.LATTICE_FORM_MESH:
+        case PatternType.COONS_PATCH_MESH:
+        case PatternType.TENSOR_PATCH_MESH:
+          return new Shadings.Mesh(shading, matrix, xref, res);
+        default:
+          throw new Error('Unknown PatternType: ' + type);
+      }
+    } catch (ex) {
+      if (ex instanceof MissingDataException) {
+        throw ex;
+      }
+      UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
+      warn(ex);
+      return new Shadings.Dummy();
     }
   };
   return Pattern;
diff --git a/test/pdfs/issue5509.pdf.link b/test/pdfs/issue5509.pdf.link
new file mode 100644
index 0000000..45aa810
--- /dev/null
+++ b/test/pdfs/issue5509.pdf.link
@@ -0,0 +1 @@
+http://web.archive.org/web/20140908142029/http://kieranhealy.org/files/papers/data-visualization.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index c93a911..0071874 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -499,6 +499,15 @@
        "link": false,
        "type": "eq"
     },
+    {  "id": "issue5509",
+       "file": "pdfs/issue5509.pdf",
+       "md5": "1975ef8db7355b1d691bc79d0749574b",
+       "rounds": 1,
+       "link": true,
+       "firstPage": 1,
+       "lastPage": 1,
+       "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