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

Unified Diff: components/policy/core/browser/url_blacklist_manager.cc

Issue 2426733002: Check for blacklist wildcards before creating GURL (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/browser/url_blacklist_manager.cc
diff --git a/components/policy/core/browser/url_blacklist_manager.cc b/components/policy/core/browser/url_blacklist_manager.cc
index e0f93b7d9ca9d89b72c2497423d5d247948dbe1f..c2ed412bb89fc7aaba2e4f65b9c7108ba8799c8c 100644
--- a/components/policy/core/browser/url_blacklist_manager.cc
+++ b/components/policy/core/browser/url_blacklist_manager.cc
@@ -262,6 +262,19 @@ bool URLBlacklist::FilterToComponents(const std::string& filter,
const std::string lc_filter = base::ToLowerASCII(filter);
const std::string url_scheme = url_formatter::SegmentURL(filter, &parsed);
+ // Check if it's a scheme wildcard pattern. We support both versions
+ // (scheme:* and scheme://*) the later being consistent with old filter
+ // definitions.
+ if (lc_filter == url_scheme + ":*" || lc_filter == url_scheme + "://*") {
+ scheme->assign(url_scheme);
+ host->clear();
+ *match_subdomains = true;
+ *port = 0;
+ path->clear();
+ query->clear();
+ return true;
+ }
+
if (url_scheme == url::kFileScheme) {
base::FilePath file_path;
if (!net::FileURLToFilePath(GURL(filter), &file_path))
@@ -271,11 +284,7 @@ bool URLBlacklist::FilterToComponents(const std::string& filter,
host->clear();
*match_subdomains = true;
*port = 0;
- // Special path when the |filter| is 'file://*' or 'file:*'.
- if (lc_filter == "file:*" || lc_filter == "file://*")
- path->clear();
- else
- *path = file_path.AsUTF8Unsafe();
+ *path = file_path.AsUTF8Unsafe();
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
// Separators have to be canonicalized on Windows.
std::replace(path->begin(), path->end(), '\\', '/');
@@ -284,19 +293,6 @@ bool URLBlacklist::FilterToComponents(const std::string& filter,
return true;
}
- // Check if it's a scheme wildcard pattern. We support both versions
- // (scheme:* and scheme://*) the later being consistent with old filter
- // definitions.
- if (lc_filter == url_scheme + ":*" || lc_filter == url_scheme + "://*") {
- scheme->assign(url_scheme);
- host->clear();
- *match_subdomains = true;
- *port = 0;
- path->clear();
- query->clear();
- return true;
- }
-
// According to documentation host can't be empty.
if (!parsed.host.is_nonempty())
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698