Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Unified Diff: components/subresource_filter/core/common/fuzzy_pattern_matching.cc

Issue 2167653002: Make the subresource filter support subdomain anchor matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments from engedy@ Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/core/common/fuzzy_pattern_matching.cc
diff --git a/components/subresource_filter/core/common/fuzzy_pattern_matching.cc b/components/subresource_filter/core/common/fuzzy_pattern_matching.cc
index d3cf29ff2c4e99a82b6444378516f499d68a37e6..96b0f5cb7876d04fa4e0b762985f367b657c8ccb 100644
--- a/components/subresource_filter/core/common/fuzzy_pattern_matching.cc
+++ b/components/subresource_filter/core/common/fuzzy_pattern_matching.cc
@@ -25,31 +25,14 @@ bool StartsWithFuzzyImpl(base::StringPiece text, base::StringPiece subpattern) {
} // namespace
bool StartsWithFuzzy(base::StringPiece text, base::StringPiece subpattern) {
- if (subpattern.size() <= text.size())
- return StartsWithFuzzyImpl(text, subpattern);
-
- return subpattern.size() == text.size() + 1 &&
- subpattern.back() == kSeparatorPlaceholder &&
- StartsWithFuzzyImpl(text, subpattern.substr(0, text.size()));
+ return subpattern.size() <= text.size() &&
+ StartsWithFuzzyImpl(text, subpattern);
}
bool EndsWithFuzzy(base::StringPiece text, base::StringPiece subpattern) {
- if (subpattern.size() > text.size() + 1)
- return false;
-
- if (subpattern.size() <= text.size() &&
- StartsWithFuzzyImpl(text.substr(text.size() - subpattern.size()),
- subpattern)) {
- return true;
- }
-
- DCHECK(!subpattern.empty());
- if (subpattern.back() != kSeparatorPlaceholder)
- return false;
- subpattern.remove_suffix(1);
- DCHECK_LE(subpattern.size(), text.size());
- return StartsWithFuzzy(text.substr(text.size() - subpattern.size()),
- subpattern);
+ return subpattern.size() <= text.size() &&
+ StartsWithFuzzyImpl(text.substr(text.size() - subpattern.size()),
+ subpattern);
}
} // namespace subresource_filter

Powered by Google App Engine
This is Rietveld 408576698