mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 09:31:01 +01:00
code review: mind length of data available
This commit is contained in:
parent
b36320c643
commit
a3f7392f06
1 changed files with 3 additions and 6 deletions
|
@ -603,6 +603,7 @@ var filterDocument = (function() {
|
||||||
}
|
}
|
||||||
// We need to insert after DOCTYPE, or else the browser may falls into
|
// We need to insert after DOCTYPE, or else the browser may falls into
|
||||||
// quirks mode.
|
// quirks mode.
|
||||||
|
if ( responseBytes.byteLength < 256 ) { return false; }
|
||||||
var bb = new Uint8Array(responseBytes, 0, 256),
|
var bb = new Uint8Array(responseBytes, 0, 256),
|
||||||
i = 0, b;
|
i = 0, b;
|
||||||
// Skip BOM if present.
|
// Skip BOM if present.
|
||||||
|
@ -638,15 +639,11 @@ var filterDocument = (function() {
|
||||||
if ( (qcount & 1) !== 0 ) { return false; }
|
if ( (qcount & 1) !== 0 ) { return false; }
|
||||||
// We found a valid insertion point.
|
// We found a valid insertion point.
|
||||||
if ( textEncoder === undefined ) { textEncoder = new TextEncoder(); }
|
if ( textEncoder === undefined ) { textEncoder = new TextEncoder(); }
|
||||||
filterer.stream.write(
|
filterer.stream.write(new Uint8Array(responseBytes, 0, i));
|
||||||
new Uint8Array(responseBytes, 0, i)
|
|
||||||
);
|
|
||||||
filterer.stream.write(
|
filterer.stream.write(
|
||||||
textEncoder.encode('<script>' + filterer.scriptlets + '</script>')
|
textEncoder.encode('<script>' + filterer.scriptlets + '</script>')
|
||||||
);
|
);
|
||||||
filterer.stream.write(
|
filterer.stream.write(new Uint8Array(responseBytes, i));
|
||||||
new Uint8Array(responseBytes, i)
|
|
||||||
);
|
|
||||||
filterer.stream.disconnect();
|
filterer.stream.disconnect();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue