[Pkg-javascript-commits] [pdf.js] 66/204: Fix loading of inline JPEG images

David Prévot taffit at moszumanska.debian.org
Sat Oct 25 18:50:32 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 2003d83ea6cfad16b147c86adfe555a998523e4c
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Sep 11 01:49:14 2014 +0200

    Fix loading of inline JPEG images
---
 src/core/parser.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/core/parser.js b/src/core/parser.js
index 4af57fb..73eb756 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -372,6 +372,22 @@ var Parser = (function ParserClosure() {
           return new LZWStream(stream, maybeLength, earlyChange);
         }
         if (name === 'DCTDecode' || name === 'DCT') {
+          // According to the specification: for inline images, the ID operator
+          // shall be followed by a single whitespace character (unless it uses
+          // ASCII85Decode or ASCIIHexDecode filters).
+          // In practice this only seems to be followed for inline JPEG images,
+          // and generally ignoring the first byte of the stream if it is a
+          // whitespace char can even *cause* issues (e.g. in the CCITTFaxDecode
+          // filters used in issue2984.pdf).
+          // Hence when the first byte of the stream of an inline JPEG image is
+          // a whitespace character, we thus simply skip over it.
+          if (isCmd(this.buf1, 'ID')) {
+            var firstByte = stream.peekByte();
+            if (firstByte === 0x0A /* LF */ || firstByte === 0x0D /* CR */ ||
+                firstByte === 0x20 /* SPACE */) {
+              stream.skip();
+            }
+          }
           xrefStreamStats[StreamType.DCT] = true;
           return new JpegStream(stream, maybeLength, stream.dict, this.xref);
         }

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