mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Use substring matching for content filters
This commit is contained in:
parent
14d62d7f31
commit
2e5edcf27e
Notes:
github-actions[bot]
2024-09-28 12:41:41 +00:00
Author: https://github.com/Gingeh Commit: https://github.com/LadybirdBrowser/ladybird/commit/2e5edcf27e7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1523
2 changed files with 4 additions and 12 deletions
|
@ -406,8 +406,8 @@ glassboxdigital.io
|
|||
go-mpulse.net
|
||||
go2speed.org
|
||||
google-analytics.com
|
||||
google.com/gen_204\?
|
||||
google.com/log\?
|
||||
google.com/gen_204?
|
||||
google.com/log?
|
||||
googleadservices.com
|
||||
googleoptimize.com
|
||||
googlesyndication.com
|
||||
|
|
|
@ -27,7 +27,7 @@ bool ContentFilter::is_filtered(const URL::URL& url) const
|
|||
auto url_string = url.to_byte_string();
|
||||
|
||||
for (auto& pattern : m_patterns) {
|
||||
if (url_string.matches(pattern.text, CaseSensitivity::CaseSensitive))
|
||||
if (url_string.find(pattern.text).has_value())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -38,15 +38,7 @@ ErrorOr<void> ContentFilter::set_patterns(ReadonlySpan<String> patterns)
|
|||
m_patterns.clear_with_capacity();
|
||||
|
||||
for (auto const& pattern : patterns) {
|
||||
StringBuilder builder;
|
||||
|
||||
if (!pattern.starts_with('*'))
|
||||
TRY(builder.try_append('*'));
|
||||
TRY(builder.try_append(pattern));
|
||||
if (!pattern.ends_with('*'))
|
||||
TRY(builder.try_append('*'));
|
||||
|
||||
TRY(m_patterns.try_empend(TRY(builder.to_string())));
|
||||
TRY(m_patterns.try_empend(pattern));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Reference in a new issue