Prevent evaluating the SNFE until fully loaded · gorhill/uBlock@89b2727 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 89b2727

Browse files
committed
Prevent evaluating the SNFE until fully loaded
Related issue: uBlockOrigin/uBlock-issues#2925
1 parent 605ad23 commit 89b2727

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/js/static-net-filtering.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,6 +4123,8 @@ FilterContainer.prototype.reset = function() {
41234123
this.optimizeTaskId = undefined;
41244124
}
41254125

4126+
this.notReady = false;
4127+
41264128
// Runtime registers
41274129
this.$catBits = 0;
41284130
this.$tokenHash = 0;
@@ -4215,6 +4217,8 @@ FilterContainer.prototype.freeze = function() {
42154217
this.goodFilters.clear();
42164218
filterArgsToUnit.clear();
42174219

4220+
this.notReady = false;
4221+
42184222
// Optimizing is not critical for the static network filtering engine to
42194223
// work properly, so defer this until later to allow for reduced delay to
42204224
// readiness when no valid selfie is available.
@@ -4723,6 +4727,8 @@ FilterContainer.prototype.fromSelfie = async function(storage, path) {
47234727

47244728
this.reset();
47254729

4730+
this.notReady = true;
4731+
47264732
const results = await Promise.all([
47274733
storage.get(`${path}/main`),
47284734
storage.get(`${path}/destHNTrieContainer`).then(details =>
@@ -4767,6 +4773,14 @@ FilterContainer.prototype.fromSelfie = async function(storage, path) {
47674773
this.bitsToBucketIndices = selfie.bitsToBucketIndices;
47684774
bucketsFromSelfie(selfie.buckets);
47694775
urlTokenizer.fromSelfie(selfie.urlTokenizer);
4776+
4777+
// If this point is never reached, it means the internal state is
4778+
// unreliable, and the caller is then responsible for resetting the
4779+
// engine and populate properly, in which case the `notReady` barrier
4780+
// will be properly reset.
4781+
4782+
this.notReady = false;
4783+
47704784
return true;
47714785
};
47724786

@@ -4811,6 +4825,8 @@ FilterContainer.prototype.matchAndFetchModifiers = function(
48114825
fctxt,
48124826
modifierName
48134827
) {
4828+
if ( this.notReady ) { return; }
4829+
48144830
const typeBits = typeNameToTypeValue[fctxt.type] || otherTypeBitValue;
48154831

48164832
$requestURL = urlTokenizer.setURL(fctxt.url);
@@ -4988,6 +5004,8 @@ FilterContainer.prototype.realmMatchString = function(
49885004
typeBits,
49895005
partyBits
49905006
) {
5007+
if ( this.notReady ) { return false; }
5008+
49915009
const exactType = typeBits & 0x80000000;
49925010
typeBits &= 0x7FFFFFFF;
49935011

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.