diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 05:15:15 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 05:15:15 +0000 |
commit | 838b943ae327185223b15337b62b3c5f41a70354 (patch) | |
tree | f6da26326065e9c760c14f0f00eef4bdacace25b /chrome/common/extensions/url_pattern.cc | |
parent | 3f79789f46d6b5d1799a82371f478cb3a15d7e07 (diff) | |
download | chromium_src-838b943ae327185223b15337b62b3c5f41a70354.zip chromium_src-838b943ae327185223b15337b62b3c5f41a70354.tar.gz chromium_src-838b943ae327185223b15337b62b3c5f41a70354.tar.bz2 |
Allow all URLPatterns to have ports.
This is a minor breaking change, but after looking at the data,
I don't think it's worth maintaining backward compat.
I will mail the authors of the extensions that are affected to
warn them.
BUG=104104
Review URL: http://codereview.chromium.org/8970020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index ba8843a..c72f98c 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -48,10 +48,7 @@ const char kParseErrorWrongSchemeType[] = "Wrong scheme type."; const char kParseErrorEmptyHost[] = "Host can not be empty."; const char kParseErrorInvalidHostWildcard[] = "Invalid host wildcard."; const char kParseErrorEmptyPath[] = "Empty path."; -const char kParseErrorHasColon[] = - "Ports are not supported in URL patterns. ':' may not be used in a host."; -const char kParseErrorInvalidPort[] = - "Invalid port."; +const char kParseErrorInvalidPort[] = "Invalid port."; // Message explaining each URLPattern::ParseResult. const char* const kParseResultMessages[] = { @@ -62,7 +59,6 @@ const char* const kParseResultMessages[] = { kParseErrorEmptyHost, kParseErrorInvalidHostWildcard, kParseErrorEmptyPath, - kParseErrorHasColon, kParseErrorInvalidPort, }; @@ -99,15 +95,13 @@ bool IsValidPortForScheme(const std::string scheme, const std::string& port) { } // namespace URLPattern::URLPattern() - : parse_option_(USE_PORTS), - valid_schemes_(SCHEME_NONE), + : valid_schemes_(SCHEME_NONE), match_all_urls_(false), match_subdomains_(false), port_("*") {} -URLPattern::URLPattern(URLPattern::ParseOption parse_option, int valid_schemes) - : parse_option_(parse_option), - valid_schemes_(valid_schemes), +URLPattern::URLPattern(int valid_schemes) + : valid_schemes_(valid_schemes), match_all_urls_(false), match_subdomains_(false), port_("*") {} @@ -115,8 +109,7 @@ URLPattern::URLPattern(URLPattern::ParseOption parse_option, int valid_schemes) URLPattern::URLPattern(int valid_schemes, const std::string& pattern) // Strict error checking is used, because this constructor is only // appropriate when we know |pattern| is valid. - : parse_option_(USE_PORTS), - valid_schemes_(valid_schemes), + : valid_schemes_(valid_schemes), match_all_urls_(false), match_subdomains_(false), port_("*") { @@ -217,20 +210,9 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { size_t port_pos = host_.find(':'); if (port_pos != std::string::npos) { - switch (parse_option_) { - case USE_PORTS: { - if (!SetPort(host_.substr(port_pos + 1))) - return PARSE_ERROR_INVALID_PORT; - host_ = host_.substr(0, port_pos); - break; - } - case ERROR_ON_PORTS: { - return PARSE_ERROR_HAS_COLON; - } - case IGNORE_PORTS: { - // Do nothing, i.e. leave the colon in the host. - } - } + if (!SetPort(host_.substr(port_pos + 1))) + return PARSE_ERROR_INVALID_PORT; + host_ = host_.substr(0, port_pos); } // No other '*' can occur in the host, though. This isn't necessary, but is @@ -247,11 +229,6 @@ void URLPattern::SetValidSchemes(int valid_schemes) { valid_schemes_ = valid_schemes; } -void URLPattern::SetParseOption(URLPattern::ParseOption parse_option) { - spec_.clear(); - parse_option_ = parse_option; -} - void URLPattern::SetHost(const std::string& host) { spec_.clear(); host_ = host; |