Skip to content

Commit

Permalink
Fix loading of inline JPEG images
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffleupagus committed Sep 11, 2014
1 parent d1974ea commit 2003d83
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 2003d83

Please sign in to comment.