Skip to content

Commit ff2d788

Browse files
authored
Merge pull request #525 from brave/include-removeparam-in-data-format
Add removeparam filters to the serialized data format
2 parents d380055 + f90057e commit ff2d788

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/data_format/storage.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ pub(crate) struct SerializeFormat<'a> {
243243
procedural_action: &'a HashMap<Hash, Vec<String>>,
244244
#[serde(serialize_with = "stabilize_hashmap_serialization")]
245245
procedural_action_exception: &'a HashMap<Hash, Vec<String>>,
246+
247+
#[serde(serialize_with = "serialize_network_filter_list")]
248+
removeparam: &'a NetworkFilterList,
246249
}
247250

248251
impl SerializeFormat<'_> {
@@ -301,6 +304,9 @@ pub(crate) struct DeserializeFormat {
301304
procedural_action: HashMap<Hash, Vec<String>>,
302305
#[serde(default)]
303306
procedural_action_exception: HashMap<Hash, Vec<String>>,
307+
308+
#[serde(default)]
309+
removeparam: NetworkFilterListDeserializeFmt,
304310
}
305311

306312
impl DeserializeFormat {
@@ -341,6 +347,8 @@ impl<'a> From<(&'a Blocker, &'a CosmeticFilterCache)> for SerializeFormat<'a> {
341347

342348
procedural_action: &cfc.specific_rules.procedural_action.0,
343349
procedural_action_exception: &cfc.specific_rules.procedural_action_exception.0,
350+
351+
removeparam: &blocker.removeparam,
344352
}
345353
}
346354
}
@@ -360,7 +368,7 @@ impl TryFrom<DeserializeFormat> for (Blocker, CosmeticFilterCache) {
360368
exceptions: v.exceptions.try_into()?,
361369
importants: v.importants.try_into()?,
362370
redirects: v.redirects.try_into()?,
363-
removeparam: NetworkFilterList::default(),
371+
removeparam: v.removeparam.try_into()?,
364372
filters: v.filters.try_into()?,
365373
generic_hide: v.generic_hide.try_into()?,
366374

tests/unit/engine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ mod tests {
183183
fn deserialization_generate_simple() {
184184
let mut engine = Engine::from_rules(["ad-banner"], Default::default());
185185
let data = engine.serialize().unwrap();
186-
const EXPECTED_HASH: u64 = 5723845290597955159;
186+
const EXPECTED_HASH: u64 = 9023363977439833140;
187187
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
188188
engine.deserialize(&data).unwrap();
189189
}
@@ -193,7 +193,7 @@ mod tests {
193193
let mut engine = Engine::from_rules(["ad-banner$tag=abc"], Default::default());
194194
engine.use_tags(&["abc"]);
195195
let data = engine.serialize().unwrap();
196-
const EXPECTED_HASH: u64 = 9626816743810307798;
196+
const EXPECTED_HASH: u64 = 17490165506820084756;
197197
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
198198
engine.deserialize(&data).unwrap();
199199
}
@@ -219,9 +219,9 @@ mod tests {
219219
let data = engine.serialize().unwrap();
220220

221221
let expected_hash = if cfg!(feature = "css-validation") {
222-
14270179196454678892
222+
11154262451234023377
223223
} else {
224-
8787095256768277705
224+
48716029470216845
225225
};
226226

227227
assert_eq!(hash(&data), expected_hash, "{}", HASH_MISMATCH_MSG);

0 commit comments

Comments
 (0)