Merge pull request #6922 from Snuffleupagus/issue-1536

Prevent failures in the "scanning for endstream" code, in `Parser_makeStream`, by handling the case where 'endstream' is split between contiguous chunks (issue 1536)
This commit is contained in:
Yury Delendik 2016-01-26 10:06:51 -06:00
commit 0558ffcbf9
4 changed files with 32 additions and 13 deletions

View File

@ -488,23 +488,22 @@ var Parser = (function ParserClosure() {
break;
}
found = false;
for (i = 0, j = 0; i < scanLength; i++) {
var b = scanBytes[i];
if (b !== ENDSTREAM_SIGNATURE[j]) {
i -= j;
j = 0;
} else {
i = 0;
while (i < scanLength) {
j = 0;
while (j < ENDSTREAM_SIGNATURE_LENGTH &&
scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
j++;
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
i++;
found = true;
break;
}
}
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
found = true;
break;
}
i++;
}
if (found) {
skipped += i - ENDSTREAM_SIGNATURE_LENGTH;
stream.pos += i - ENDSTREAM_SIGNATURE_LENGTH;
skipped += i;
stream.pos += i;
break;
}
skipped += scanLength;

View File

@ -0,0 +1 @@
http://web.archive.org/web/20150922201828/http://w2.eff.org/legal/cases/betamax/betamax_oral_argument2.pdf

View File

@ -0,0 +1 @@
http://web.archive.org/web/20160125220711/http://www.star.bnl.gov/public/daq/HARDWARE/21264_data_sheet.pdf

View File

@ -921,6 +921,24 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue1536",
"file": "pdfs/issue1536.pdf",
"md5": "bcaa52e6216399592ad5aa9fc49f1436",
"rounds": 1,
"link": true,
"firstPage": 6,
"lastPage": 6,
"type": "eq"
},
{ "id": "issue2098",
"file": "pdfs/issue2098.pdf",
"md5": "e9fa2b7cb935ffb95b510322d1e047e1",
"rounds": 1,
"link": true,
"firstPage": 1,
"lastPage": 1,
"type": "eq"
},
{ "id": "bpl13210",
"file": "pdfs/bpl13210.pdf",
"md5": "8a08512baa9fa95378d9ad4b995947c7",