mirror of https://github.com/gorhill/uBlock.git
Use a better value to mark end of sequence of tokens
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2041 The value 0xFFFFFFFF will be used instead of 0 to mark the end of a sequence of tokens, as the value 0xFFFFFFFF can't happen as a result of computing a token hash, since the four most significant bits are always 0 in a computed token hash.
This commit is contained in:
parent
858fdaced3
commit
bc4f392a47
|
@ -176,6 +176,7 @@ const ANY_TOKEN_HASH = 0x20000000;
|
||||||
const ANY_HTTPS_TOKEN_HASH = 0x30000000;
|
const ANY_HTTPS_TOKEN_HASH = 0x30000000;
|
||||||
const ANY_HTTP_TOKEN_HASH = 0x40000000;
|
const ANY_HTTP_TOKEN_HASH = 0x40000000;
|
||||||
const EMPTY_TOKEN_HASH = 0xF0000000;
|
const EMPTY_TOKEN_HASH = 0xF0000000;
|
||||||
|
const INVALID_TOKEN_HASH = 0xFFFFFFFF;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -2581,7 +2582,7 @@ const urlTokenizer = new (class {
|
||||||
}
|
}
|
||||||
this._tokens[i+0] = NO_TOKEN_HASH;
|
this._tokens[i+0] = NO_TOKEN_HASH;
|
||||||
this._tokens[i+1] = 0;
|
this._tokens[i+1] = 0;
|
||||||
this._tokens[i+2] = 0;
|
this._tokens[i+2] = INVALID_TOKEN_HASH;
|
||||||
this._tokenized = true;
|
this._tokenized = true;
|
||||||
return this._tokens;
|
return this._tokens;
|
||||||
}
|
}
|
||||||
|
@ -3981,7 +3982,7 @@ FilterContainer.prototype.matchAndFetchModifiers = function(
|
||||||
let th = 0, iunit = 0;
|
let th = 0, iunit = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
th = tokenHashes[i];
|
th = tokenHashes[i];
|
||||||
if ( th === 0 ) { break; }
|
if ( th === INVALID_TOKEN_HASH ) { break; }
|
||||||
env.th = th;
|
env.th = th;
|
||||||
$tokenBeg = tokenHashes[i+1];
|
$tokenBeg = tokenHashes[i+1];
|
||||||
if (
|
if (
|
||||||
|
@ -4173,7 +4174,7 @@ FilterContainer.prototype.realmMatchString = function(
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
tokenHash = tokenHashes[i];
|
tokenHash = tokenHashes[i];
|
||||||
if ( tokenHash === 0 ) { return false; }
|
if ( tokenHash === INVALID_TOKEN_HASH ) { return false; }
|
||||||
$tokenBeg = tokenHashes[i+1];
|
$tokenBeg = tokenHashes[i+1];
|
||||||
if (
|
if (
|
||||||
(ibucket00 !== 0) &&
|
(ibucket00 !== 0) &&
|
||||||
|
|
Loading…
Reference in New Issue