diff --git a/components/brave_shields/adblock/rs/Cargo.toml b/components/brave_shields/adblock/rs/Cargo.toml index 9cd6791233ec..3f1548c56f4b 100644 --- a/components/brave_shields/adblock/rs/Cargo.toml +++ b/components/brave_shields/adblock/rs/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -adblock = { version = "0.8.1", default-features = false, features = ["full-regex-handling", "regex-debug-info", "css-validation"] } +adblock = { version = "0.8.2", default-features = false, features = ["full-regex-handling", "regex-debug-info", "css-validation"] } cxx = "1.0" serde_json = "1.0" thiserror = "1.0" diff --git a/third_party/rust/Cargo.lock b/third_party/rust/Cargo.lock index 9ad14a87b29c..e571d9a7de11 100644 --- a/third_party/rust/Cargo.lock +++ b/third_party/rust/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "adblock" -version = "0.8.1" +version = "0.8.2" dependencies = [ "base64", "bitflags", diff --git a/third_party/rust/adblock/v0_8/README.chromium b/third_party/rust/adblock/v0_8/README.chromium index 0eca9fb5306d..69fda8f94795 100644 --- a/third_party/rust/adblock/v0_8/README.chromium +++ b/third_party/rust/adblock/v0_8/README.chromium @@ -1,7 +1,7 @@ Name: adblock URL: https://crates.io/crates/adblock Description: Native Rust module for Adblock Plus syntax (e.g. EasyList, EasyPrivacy) filter parsing and matching. -Version: 0.8.1 +Version: 0.8.2 Security Critical: no License: Mozilla Public License 2.0 -Revision: bc39fa8a52bc96db18e8c14de73ed63d883a7b09 +Revision: 949a6e159a7289332da1df966d4565876adc5c3c diff --git a/third_party/rust/adblock/v0_8/crate/.cargo_vcs_info.json b/third_party/rust/adblock/v0_8/crate/.cargo_vcs_info.json index 021833609e52..664fea55cfc1 100644 --- a/third_party/rust/adblock/v0_8/crate/.cargo_vcs_info.json +++ b/third_party/rust/adblock/v0_8/crate/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "bc39fa8a52bc96db18e8c14de73ed63d883a7b09" + "sha1": "949a6e159a7289332da1df966d4565876adc5c3c" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/third_party/rust/adblock/v0_8/crate/Cargo.lock b/third_party/rust/adblock/v0_8/crate/Cargo.lock index ae63b8c94c87..4a020a8b5ed5 100644 --- a/third_party/rust/adblock/v0_8/crate/Cargo.lock +++ b/third_party/rust/adblock/v0_8/crate/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "adblock" -version = "0.8.1" +version = "0.8.2" dependencies = [ "addr", "base64", @@ -1653,9 +1653,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", diff --git a/third_party/rust/adblock/v0_8/crate/Cargo.toml b/third_party/rust/adblock/v0_8/crate/Cargo.toml index b51e864eeed3..8f33bbd0ee2c 100644 --- a/third_party/rust/adblock/v0_8/crate/Cargo.toml +++ b/third_party/rust/adblock/v0_8/crate/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2021" name = "adblock" -version = "0.8.1" +version = "0.8.2" authors = [ "Andrius Aucinas ", "Anton Lazarev ", diff --git a/third_party/rust/adblock/v0_8/crate/Cargo.toml.orig b/third_party/rust/adblock/v0_8/crate/Cargo.toml.orig index f2432f9892c3..c2e281ed6fa6 100644 --- a/third_party/rust/adblock/v0_8/crate/Cargo.toml.orig +++ b/third_party/rust/adblock/v0_8/crate/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "adblock" -version = "0.8.1" +version = "0.8.2" authors = ["Andrius Aucinas ", "Anton Lazarev "] edition = "2021" diff --git a/third_party/rust/adblock/v0_8/crate/benches/bench_redirect_performance.rs b/third_party/rust/adblock/v0_8/crate/benches/bench_redirect_performance.rs index 11996ba4fd19..fa562c5abf76 100644 --- a/third_party/rust/adblock/v0_8/crate/benches/bench_redirect_performance.rs +++ b/third_party/rust/adblock/v0_8/crate/benches/bench_redirect_performance.rs @@ -7,7 +7,7 @@ use adblock::request::Request; use adblock::resources::ResourceStorage; const DEFAULT_LISTS_URL: &str = - "https://raw.githubusercontent.com/brave/adblock-resources/master/filter_lists/default.json"; + "https://raw.githubusercontent.com/brave/adblock-resources/master/filter_lists/list_catalog.json"; async fn get_all_filters() -> Vec { use futures::FutureExt; diff --git a/third_party/rust/adblock/v0_8/crate/src/cosmetic_filter_cache.rs b/third_party/rust/adblock/v0_8/crate/src/cosmetic_filter_cache.rs index a62f3cb2245f..7062f3101848 100644 --- a/third_party/rust/adblock/v0_8/crate/src/cosmetic_filter_cache.rs +++ b/third_party/rust/adblock/v0_8/crate/src/cosmetic_filter_cache.rs @@ -248,6 +248,8 @@ impl CosmeticFilterCache { let mut script_injections = HashMap::<&str, PermissionMask>::new(); let mut exceptions = HashSet::new(); + let mut except_all_scripts = false; + let hashes: Vec<&Hash> = request_entities.iter().chain(request_hostnames.iter()).collect(); fn populate_set(hash: &Hash, source_bin: &HostnameFilterBin, dest_set: &mut HashSet) { @@ -308,9 +310,16 @@ impl CosmeticFilterCache { prune_set(hash, &self.specific_rules.unremove, &mut remove_selectors); // same logic but not using prune_set since strings are unowned, (see above) if let Some(s) = self.specific_rules.uninject_script.get(hash) { - s.iter().for_each(|s| { + for s in s { + if s.is_empty() { + except_all_scripts = true; + script_injections.clear(); + } + if except_all_scripts { + continue; + } script_injections.remove(s.as_str()); - }); + } } prune_map(hash, &self.specific_rules.unstyle, &mut style_selectors); @@ -657,6 +666,7 @@ mod cosmetic_cache_tests { "cosmetic.net##+js(nowebrtc.js)", "g.cosmetic.net##+js(window.open-defuser.js)", "c.g.cosmetic.net#@#+js(nowebrtc.js)", + "d.g.cosmetic.net#@#+js()", ]); let resources = ResourceStorage::from_resources([ Resource { @@ -698,6 +708,10 @@ mod cosmetic_cache_tests { let out = cfcache.hostname_cosmetic_resources(&resources, "c.g.cosmetic.net", false); expected.injected_script = "try {\nwindow.open-defuser.js\n} catch ( e ) { }\n".to_owned(); assert_eq!(out, expected); + + let out = cfcache.hostname_cosmetic_resources(&resources, "d.g.cosmetic.net", false); + expected.injected_script = "".to_owned(); + assert_eq!(out, expected); } #[test] diff --git a/third_party/rust/adblock/v0_8/crate/src/engine.rs b/third_party/rust/adblock/v0_8/crate/src/engine.rs index 204f45529c59..083a2601b299 100644 --- a/third_party/rust/adblock/v0_8/crate/src/engine.rs +++ b/third_party/rust/adblock/v0_8/crate/src/engine.rs @@ -213,11 +213,11 @@ impl Engine { /// `hidden_class_id_selectors` to obtain any stylesheets consisting of generic rules (if the /// returned `generichide` value is false). pub fn url_cosmetic_resources(&self, url: &str) -> UrlSpecificResources { - let request = Request::new(url, url, "document"); - if request.is_err() { + let request = if let Ok(request) = Request::new(url, url, "document") { + request + } else { return UrlSpecificResources::empty(); - } - let request = request.unwrap(); + }; let generichide = self.blocker.check_generic_hide(&request); self.cosmetic_cache.hostname_cosmetic_resources(&self.resources, &request.hostname, generichide) diff --git a/third_party/rust/third_party.toml b/third_party/rust/third_party.toml index 738be4eb4017..e1bbeb406094 100644 --- a/third_party/rust/third_party.toml +++ b/third_party/rust/third_party.toml @@ -228,7 +228,7 @@ if (is_mac) { ''' [dependencies.adblock] -version = "0.8.1" +version = "0.8.2" default-features = false features = ["full-regex-handling", "regex-debug-info", "css-validation"] gn-variables-lib = '''