Improves search of EI (end of inlined image)

This commit is contained in:
Yury Delendik 2013-06-21 17:03:03 -05:00
parent ce218d021f
commit c68d125f17
4 changed files with 30 additions and 1 deletions

View File

@ -154,13 +154,22 @@ var Parser = (function ParserClosure() {
var startPos = stream.pos;
// searching for the /EI\s/
var state = 0, ch;
var state = 0, ch, i, ii;
while (state != 4 &&
(ch = stream.getByte()) !== null && ch !== undefined) {
switch (ch) {
case 0x20:
case 0x0D:
case 0x0A:
// let's check next five bytes to be ASCII... just be sure
var followingBytes = stream.peekBytes(5);
for (i = 0, ii = followingBytes.length; i < ii; i++) {
ch = followingBytes[i];
if (ch !== 0x0A && ch != 0x0D && (ch < 0x20 || ch > 0x7F)) {
state = 0;
break; // some binary stuff found, resetting the state
}
}
state = state === 3 ? 4 : 0;
break;
case 0x45:

View File

@ -57,6 +57,11 @@ var Stream = (function StreamClosure() {
this.pos = end;
return bytes.subarray(pos, end);
},
peekBytes: function Stream_peekBytes(length) {
var bytes = this.getBytes(length);
this.pos -= bytes.length;
return bytes;
},
lookChar: function Stream_lookChar() {
if (this.pos >= this.end)
return null;
@ -161,6 +166,11 @@ var DecodeStream = (function DecodeStreamClosure() {
this.pos = end;
return this.buffer.subarray(pos, end);
},
peekBytes: function DecodeStream_peekBytes(length) {
var bytes = this.getBytes(length);
this.pos -= bytes.length;
return bytes;
},
lookChar: function DecodeStream_lookChar() {
var pos = this.pos;
while (this.bufferLength <= pos) {

View File

@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=756735

View File

@ -1104,6 +1104,15 @@
"type": "eq",
"about": "True type font with encoding dict with no base encoding but with differences."
},
{ "id": "bug878194",
"file": "pdfs/bug878194.pdf",
"md5": "c616b21fd2a1a65acc2de0f41e59a8b5",
"link": "true",
"rounds": 1,
"firstPage": 4,
"lastPage": 4,
"type": "load"
},
{ "id": "p020121130574743273239",
"file": "pdfs/P020121130574743273239.pdf",
"md5": "271b65885d42d174cbc597ca89becb1a",