[Pkg-javascript-commits] [pdf.js] 115/157: Check if the `Decode` entry is non-default when deciding if JPEG images are natively supported/decodable (issue 6238)

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:46 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 385e2e5aaf07df8c5e581fbf7668947e5f3660a9
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Mon Jul 20 23:30:05 2015 +0200

    Check if the `Decode` entry is non-default when deciding if JPEG images are natively supported/decodable (issue 6238)
    
    Tentatively fixes 6238.
---
 src/core/colorspace.js       | 2 +-
 src/core/stream.js           | 7 ++++---
 test/pdfs/issue6238.pdf.link | 1 +
 test/test_manifest.json      | 9 +++++++++
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/core/colorspace.js b/src/core/colorspace.js
index 6277e86..e74d3f9 100644
--- a/src/core/colorspace.js
+++ b/src/core/colorspace.js
@@ -351,7 +351,7 @@ var ColorSpace = (function ColorSpaceClosure() {
    * @param {Number} n Number of components the color space has.
    */
   ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
-    if (!decode) {
+    if (!isArray(decode)) {
       return true;
     }
 
diff --git a/src/core/stream.js b/src/core/stream.js
index 2b81c6a..b6457bd 100644
--- a/src/core/stream.js
+++ b/src/core/stream.js
@@ -942,7 +942,8 @@ var JpegStream = (function JpegStreamClosure() {
   JpegStream.prototype.isNativelySupported =
       function JpegStream_isNativelySupported(xref, res) {
     var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
-    return cs.name === 'DeviceGray' || cs.name === 'DeviceRGB';
+    return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') &&
+           cs.isDefaultDecode(this.dict.get('Decode', 'D'));
   };
   /**
    * Checks if the image can be decoded by the browser.
@@ -950,8 +951,8 @@ var JpegStream = (function JpegStreamClosure() {
   JpegStream.prototype.isNativelyDecodable =
       function JpegStream_isNativelyDecodable(xref, res) {
     var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
-    var numComps = cs.numComps;
-    return numComps === 1 || numComps === 3;
+    return (cs.numComps === 1 || cs.numComps === 3) &&
+           cs.isDefaultDecode(this.dict.get('Decode', 'D'));
   };
 
   return JpegStream;
diff --git a/test/pdfs/issue6238.pdf.link b/test/pdfs/issue6238.pdf.link
new file mode 100644
index 0000000..5597a44
--- /dev/null
+++ b/test/pdfs/issue6238.pdf.link
@@ -0,0 +1 @@
+http://web.archive.org/web/20150720164240/http://fqa.9front.org/dash1.kaptnblaubar.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 43d01e4..5ecd5b7 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1338,6 +1338,15 @@
        "lastPage": 6,
        "type": "eq"
     },
+    {  "id": "issue6238",
+       "file": "pdfs/issue6238.pdf",
+       "md5": "6d7731ee22fbbdf746c8da01b8922d50",
+       "rounds": 1,
+       "link": true,
+       "firstPage": 3,
+       "lastPage": 3,
+       "type": "eq"
+    },
     {  "id": "cid_cff",
       "file": "pdfs/cid_cff.pdf",
       "md5": "a19a18eaa626262cc45e0760004d6de9",

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