@@ -51,15 +51,18 @@ pub struct BlockerResult {
51
51
/// modified at all, the new version will be here. This should be used
52
52
/// as long as the request is not blocked.
53
53
pub rewritten_url : Option < String > ,
54
- /// Exception is `Some` when the blocker matched on an exception rule.
54
+ /// Contains a string representation of any matched exception rule.
55
55
/// Effectively this means that there was a match, but the request should
56
- /// not be blocked. It is a non-empty string if the blocker was initialized
57
- /// from a list of rules with debugging enabled, otherwise the original
58
- /// string representation is discarded to reduce memory use.
56
+ /// not be blocked.
57
+ ///
58
+ /// If debugging was _not_ enabled (see [`crate::FilterSet::new`]), this
59
+ /// will only contain a constant `"NetworkFilter"` placeholder string.
59
60
pub exception : Option < String > ,
60
- /// Filter--similarly to exception--includes the string representation of
61
- /// the rule when there is a match and debugging is enabled. Otherwise, on
62
- /// a match, it is `Some`.
61
+ /// When `matched` is true, this contains a string representation of the
62
+ /// matched blocking rule.
63
+ ///
64
+ /// If debugging was _not_ enabled (see [`crate::FilterSet::new`]), this
65
+ /// will only contain a constant `"NetworkFilter"` placeholder string.
63
66
pub filter : Option < String > ,
64
67
}
65
68
@@ -2119,6 +2122,19 @@ fn test_removeparam_same_tokens() {
2119
2122
}
2120
2123
}
2121
2124
2125
+ #[ cfg( test) ]
2126
+ mod placeholder_string_tests {
2127
+ /// If this changes, be sure to update the documentation for [`BlockerResult`] as well.
2128
+ #[ test]
2129
+ fn test_constant_placeholder_string ( ) {
2130
+ let mut filter_set = crate :: lists:: FilterSet :: new ( false ) ;
2131
+ filter_set. add_filter ( "||example.com^" , Default :: default ( ) ) . unwrap ( ) ;
2132
+ let engine = crate :: Engine :: from_filter_set ( filter_set, true ) ;
2133
+ let block = engine. check_network_request ( & crate :: request:: Request :: new ( "https://example.com" , "https://example.com" , "document" ) . unwrap ( ) ) ;
2134
+ assert_eq ! ( block. filter, Some ( "NetworkFilter" . to_string( ) ) ) ;
2135
+ }
2136
+ }
2137
+
2122
2138
#[ cfg( test) ]
2123
2139
mod legacy_rule_parsing_tests {
2124
2140
use crate :: test_utils:: rules_from_lists;
0 commit comments