Skip to content

Commit 6932f41

Browse files
committed
remove IS_UNICODE from CosmeticFilterMask
the info has never been used, and it's trivial to check by inspecting the strings of a rule anyways.
1 parent 319f88b commit 6932f41

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/filters/cosmetic.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ bitflags::bitflags! {
8888
pub struct CosmeticFilterMask: u8 {
8989
const UNHIDE = 1 << 0;
9090
const SCRIPT_INJECT = 1 << 1;
91-
const IS_UNICODE = 1 << 2;
9291
const IS_CLASS_SELECTOR = 1 << 3;
9392
const IS_ID_SELECTOR = 1 << 4;
9493
const IS_SIMPLE = 1 << 5;
@@ -174,7 +173,6 @@ impl CosmeticFilter {
174173
fn parse_before_sharp(
175174
line: &str,
176175
sharp_index: usize,
177-
mask: &mut CosmeticFilterMask,
178176
) -> Result<CosmeticFilterLocations, CosmeticFilterError> {
179177
let mut entities_vec = vec![];
180178
let mut not_entities_vec = vec![];
@@ -190,7 +188,6 @@ impl CosmeticFilter {
190188
if location.is_ascii() {
191189
hostname.push_str(location);
192190
} else {
193-
*mask |= CosmeticFilterMask::IS_UNICODE;
194191
match idna::domain_to_ascii(location) {
195192
Ok(x) if !x.is_empty() => hostname.push_str(&x),
196193
_ => return Err(CosmeticFilterError::PunycodeError),
@@ -339,7 +336,7 @@ impl CosmeticFilter {
339336
hostnames,
340337
not_hostnames,
341338
} = if sharp_index > 0 {
342-
CosmeticFilter::parse_before_sharp(line, sharp_index, &mut mask)?
339+
CosmeticFilter::parse_before_sharp(line, sharp_index)?
343340
} else {
344341
CosmeticFilterLocations::default()
345342
};
@@ -385,10 +382,6 @@ impl CosmeticFilter {
385382
return Err(CosmeticFilterError::DoubleNegation);
386383
}
387384

388-
if !selector.is_ascii() {
389-
mask |= CosmeticFilterMask::IS_UNICODE;
390-
}
391-
392385
let key = if !mask.contains(CosmeticFilterMask::SCRIPT_INJECT) {
393386
if selector.starts_with('.') {
394387
let key = key_from_selector(&selector)?;
@@ -1035,7 +1028,6 @@ mod parse_tests {
10351028

10361029
unhide: bool,
10371030
script_inject: bool,
1038-
is_unicode: bool,
10391031
is_class_selector: bool,
10401032
is_id_selector: bool,
10411033
}
@@ -1053,7 +1045,6 @@ mod parse_tests {
10531045

10541046
unhide: filter.mask.contains(CosmeticFilterMask::UNHIDE),
10551047
script_inject: filter.mask.contains(CosmeticFilterMask::SCRIPT_INJECT),
1056-
is_unicode: filter.mask.contains(CosmeticFilterMask::IS_UNICODE),
10571048
is_class_selector: filter.mask.contains(CosmeticFilterMask::IS_CLASS_SELECTOR),
10581049
is_id_selector: filter.mask.contains(CosmeticFilterMask::IS_ID_SELECTOR),
10591050
}
@@ -1079,7 +1070,6 @@ mod parse_tests {
10791070

10801071
unhide: false,
10811072
script_inject: false,
1082-
is_unicode: false,
10831073
is_class_selector: false,
10841074
is_id_selector: false,
10851075
}
@@ -1620,7 +1610,6 @@ mod parse_tests {
16201610
"###неделя",
16211611
CosmeticFilterBreakdown {
16221612
selector: "#неделя".to_string(),
1623-
is_unicode: true,
16241613
is_id_selector: true,
16251614
key: Some("неделя".to_string()),
16261615
..Default::default()
@@ -1631,7 +1620,6 @@ mod parse_tests {
16311620
CosmeticFilterBreakdown {
16321621
selector: "#week".to_string(),
16331622
hostnames: sort_hash_domains(vec!["xn--lloworl-5ggb3f.com"]),
1634-
is_unicode: true,
16351623
is_id_selector: true,
16361624
key: Some("week".to_string()),
16371625
unhide: true,

0 commit comments

Comments
 (0)