mirror of https://github.com/gorhill/uBlock.git
Fix spurious 256-char limit for filters stored in bidi-trie
Plain filters can be any length, while the bidi-trie was assuming max length of 256. The origin of this error is from when the bidi-trie code was originally imported from the hntrie code as start to develop bidi-trie. The erroneous code could cause issue when the following conditions were met: - Plain filter longer than 256 characters - Free space in bidi-trie's character buffer was less than 256 bytes Likely a rare occurrence, but some filter lists do contains long plain filters, for example: https://gitlab.com/curben/urlhaus-filter/raw/master/urlhaus-filter.txt Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/cs1y26/
This commit is contained in:
parent
87cb3502b2
commit
fb4e94f92c
|
@ -241,20 +241,20 @@ const SEGMENT_INFO = 2;
|
|||
add(iroot, a, i = 0) {
|
||||
const aR = a.length;
|
||||
if ( aR === 0 ) { return 0; }
|
||||
let icell = iroot;
|
||||
// special case: first node in trie
|
||||
if ( this.buf32[icell+SEGMENT_INFO] === 0 ) {
|
||||
this.buf32[icell+SEGMENT_INFO] = this.addSegment(a, i, aR);
|
||||
return this.addLeft(icell, a, i);
|
||||
}
|
||||
// grow buffer if needed
|
||||
if (
|
||||
(this.buf32[CHAR0_SLOT] - this.buf32[TRIE1_SLOT]) < MIN_FREE_CELL_BYTE_LENGTH ||
|
||||
(this.buf.length - this.buf32[CHAR1_SLOT]) < 256
|
||||
(this.buf.length - this.buf32[CHAR1_SLOT]) < aR
|
||||
) {
|
||||
this.growBuf(MIN_FREE_CELL_BYTE_LENGTH, 256);
|
||||
this.growBuf(MIN_FREE_CELL_BYTE_LENGTH, aR);
|
||||
}
|
||||
const buf32 = this.buf32;
|
||||
let icell = iroot;
|
||||
// special case: first node in trie
|
||||
if ( buf32[icell+SEGMENT_INFO] === 0 ) {
|
||||
buf32[icell+SEGMENT_INFO] = this.addSegment(a, i, aR);
|
||||
return this.addLeft(icell, a, i);
|
||||
}
|
||||
const buf8 = this.buf;
|
||||
const char0 = buf32[CHAR0_SLOT];
|
||||
let al = i;
|
||||
|
|
Loading…
Reference in New Issue