Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/data_format/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ pub(crate) struct SerializeFormat<'a> {
procedural_action: &'a HashMap<Hash, Vec<String>>,
#[serde(serialize_with = "stabilize_hashmap_serialization")]
procedural_action_exception: &'a HashMap<Hash, Vec<String>>,

#[serde(serialize_with = "serialize_network_filter_list")]
removeparam: &'a NetworkFilterList,
}

impl SerializeFormat<'_> {
Expand Down Expand Up @@ -301,6 +304,9 @@ pub(crate) struct DeserializeFormat {
procedural_action: HashMap<Hash, Vec<String>>,
#[serde(default)]
procedural_action_exception: HashMap<Hash, Vec<String>>,

#[serde(default)]
removeparam: NetworkFilterListDeserializeFmt,
}

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

procedural_action: &cfc.specific_rules.procedural_action.0,
procedural_action_exception: &cfc.specific_rules.procedural_action_exception.0,

removeparam: &blocker.removeparam,
}
}
}
Expand All @@ -360,7 +368,7 @@ impl TryFrom<DeserializeFormat> for (Blocker, CosmeticFilterCache) {
exceptions: v.exceptions.try_into()?,
importants: v.importants.try_into()?,
redirects: v.redirects.try_into()?,
removeparam: NetworkFilterList::default(),
removeparam: v.removeparam.try_into()?,
filters: v.filters.try_into()?,
generic_hide: v.generic_hide.try_into()?,

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {
fn deserialization_generate_simple() {
let mut engine = Engine::from_rules(["ad-banner"], Default::default());
let data = engine.serialize().unwrap();
const EXPECTED_HASH: u64 = 5723845290597955159;
const EXPECTED_HASH: u64 = 9023363977439833140;
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
engine.deserialize(&data).unwrap();
}
Expand All @@ -193,7 +193,7 @@ mod tests {
let mut engine = Engine::from_rules(["ad-banner$tag=abc"], Default::default());
engine.use_tags(&["abc"]);
let data = engine.serialize().unwrap();
const EXPECTED_HASH: u64 = 9626816743810307798;
const EXPECTED_HASH: u64 = 17490165506820084756;
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
engine.deserialize(&data).unwrap();
}
Expand All @@ -219,9 +219,9 @@ mod tests {
let data = engine.serialize().unwrap();

let expected_hash = if cfg!(feature = "css-validation") {
14270179196454678892
11154262451234023377
} else {
8787095256768277705
48716029470216845
};

assert_eq!(hash(&data), expected_hash, "{}", HASH_MISMATCH_MSG);
Expand Down
Loading