diff options
-rw-r--r-- | chrome/browser/chromeos/drive/file_system_util.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/api/tabs/tabs_api.cc | 2 | ||||
-rw-r--r-- | chrome_frame/navigation_constraints.cc | 2 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 2 | ||||
-rw-r--r-- | content/browser/browser_url_handler_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/child_process_security_policy_impl.cc | 4 | ||||
-rw-r--r-- | url/gurl.cc | 4 | ||||
-rw-r--r-- | url/gurl.h | 5 | ||||
-rw-r--r-- | url/third_party/mozilla/url_parse.cc | 9 | ||||
-rw-r--r-- | url/third_party/mozilla/url_parse.h | 15 |
11 files changed, 39 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 40acfd7..bb87873 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -198,7 +198,7 @@ base::FilePath DriveURLToFilePath(const GURL& url) { if (!url.is_valid() || url.scheme() != chrome::kDriveScheme) return base::FilePath(); std::string path_string = net::UnescapeURLComponent( - url.path(), net::UnescapeRule::NORMAL); + url.GetContent(), net::UnescapeRule::NORMAL); return base::FilePath::FromUTF8Unsafe(path_string); } diff --git a/chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc b/chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc index c8f0371..2d7bac1 100644 --- a/chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc +++ b/chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc @@ -113,11 +113,11 @@ void GaiaWebAuthFlow::OnAuthFlowURLChange(const GURL& url) { // interpreted as a path, including the fragment. if (url.scheme() == redirect_scheme_ && !url.has_host() && !url.has_port() && - StartsWithASCII(url.path(), redirect_path_prefix_, true)) { + StartsWithASCII(url.GetContent(), redirect_path_prefix_, true)) { web_flow_.release()->DetachDelegateAndDelete(); - std::string fragment = - url.path().substr(redirect_path_prefix_.length(), std::string::npos); + std::string fragment = url.GetContent().substr( + redirect_path_prefix_.length(), std::string::npos); std::vector<std::pair<std::string, std::string> > pairs; base::SplitStringIntoKeyValuePairs(fragment, '=', '&', &pairs); std::string access_token; diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc index f99ef55..2cb3959 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc @@ -1345,7 +1345,7 @@ bool TabsUpdateFunction::UpdateURL(const std::string &url_string, script_executor()->ExecuteScript( extension_id(), ScriptExecutor::JAVASCRIPT, - url.path(), + url.GetContent(), ScriptExecutor::TOP_FRAME, UserScript::DOCUMENT_IDLE, ScriptExecutor::MAIN_WORLD, diff --git a/chrome_frame/navigation_constraints.cc b/chrome_frame/navigation_constraints.cc index 59efb0e..18d8d9d 100644 --- a/chrome_frame/navigation_constraints.cc +++ b/chrome_frame/navigation_constraints.cc @@ -32,7 +32,7 @@ bool NavigationConstraintsImpl::IsSchemeAllowed(const GURL& url) { // Additional checking for view-source. Allow only http and https // URLs in view source. if (url.SchemeIs(content::kViewSourceScheme)) { - GURL sub_url(url.path()); + GURL sub_url(url.GetContent()); if (sub_url.SchemeIs(content::kHttpScheme) || sub_url.SchemeIs(content::kHttpsScheme)) return true; diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 7c8b713..a00f503 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1009,7 +1009,7 @@ bool IsValidUrlScheme(const GURL& url, bool is_privileged) { // Additional checking for view-source. Allow only http and https // URLs in view source. if (url.SchemeIs(content::kViewSourceScheme)) { - GURL sub_url(url.path()); + GURL sub_url(url.GetContent()); if (sub_url.SchemeIs(content::kHttpScheme) || sub_url.SchemeIs(content::kHttpsScheme)) return true; diff --git a/content/browser/browser_url_handler_impl.cc b/content/browser/browser_url_handler_impl.cc index e642e1f..d22b88f 100644 --- a/content/browser/browser_url_handler_impl.cc +++ b/content/browser/browser_url_handler_impl.cc @@ -19,7 +19,7 @@ namespace content { static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { if (url->SchemeIs(kViewSourceScheme)) { // Load the inner URL instead. - *url = GURL(url->path()); + *url = GURL(url->GetContent()); // Bug 26129: limit view-source to view the content and not any // other kind of 'active' url scheme like 'javascript' or 'data'. diff --git a/content/browser/child_process_security_policy_impl.cc b/content/browser/child_process_security_policy_impl.cc index 5e069c4..b8433c0 100644 --- a/content/browser/child_process_security_policy_impl.cc +++ b/content/browser/child_process_security_policy_impl.cc @@ -391,7 +391,7 @@ void ChildProcessSecurityPolicyImpl::GrantRequestURL( // view-source:http://www.google.com/a // In order to request these URLs, the child_id needs to be able to // request the embedded URL. - GrantRequestURL(child_id, GURL(url.path())); + GrantRequestURL(child_id, GURL(url.GetContent())); } return; // Can't grant the capability to request pseudo schemes. @@ -572,7 +572,7 @@ bool ChildProcessSecurityPolicyImpl::CanRequestURL( if (url.SchemeIs(kViewSourceScheme)) { // A view-source URL is allowed if the child process is permitted to // request the embedded URL. Careful to avoid pointless recursion. - GURL child_url(url.path()); + GURL child_url(url.GetContent()); if (child_url.SchemeIs(kViewSourceScheme) && url.SchemeIs(kViewSourceScheme)) return false; diff --git a/url/gurl.cc b/url/gurl.cc index 559b386..60850e6 100644 --- a/url/gurl.cc +++ b/url/gurl.cc @@ -422,6 +422,10 @@ std::string GURL::HostNoBrackets() const { return ComponentString(h); } +std::string GURL::GetContent() const { + return is_valid_ ? ComponentString(parsed_.GetContent()) : std::string(); +} + bool GURL::HostIsIPAddress() const { if (!is_valid_ || spec_.empty()) return false; @@ -227,6 +227,11 @@ class URL_EXPORT GURL { (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); } + // The "content" of the URL is everything after the scheme (skipping the + // scheme delimiting colon). It is an error to get the origin of an invalid + // URL. The result will be an empty string. + std::string GetContent() const; + // Returns true if the hostname is an IP address. Note: this function isn't // as cheap as a simple getter because it re-parses the hostname to verify. // This currently identifies only IPv4 addresses (bug 822685). diff --git a/url/third_party/mozilla/url_parse.cc b/url/third_party/mozilla/url_parse.cc index 52c6196..fbc8a9b 100644 --- a/url/third_party/mozilla/url_parse.cc +++ b/url/third_party/mozilla/url_parse.cc @@ -792,6 +792,15 @@ int Parsed::CountCharactersBefore(ComponentType type, return cur; } +Component Parsed::GetContent() const { + const int begin = CountCharactersBefore(USERNAME, false); + const int len = Length() - begin; + // For compatability with the standard URL parser, we treat no content as + // -1, rather than having a length of 0 (we normally wouldn't care so + // much for these non-standard URLs). + return len ? Component(begin, len) : Component(); +} + bool ExtractScheme(const char* url, int url_len, Component* scheme) { return DoExtractScheme(url, url_len, scheme); } diff --git a/url/third_party/mozilla/url_parse.h b/url/third_party/mozilla/url_parse.h index fd974f8..5fa9322 100644 --- a/url/third_party/mozilla/url_parse.h +++ b/url/third_party/mozilla/url_parse.h @@ -159,10 +159,11 @@ struct URL_EXPORT Parsed { // Port number. Component port; - // Path, this is everything following the host name. Length will be -1 if - // unspecified. This includes the preceeding slash, so the path on - // http://www.google.com/asdf" is "/asdf". As a result, it is impossible to - // have a 0 length path, it will be -1 in cases like "http://host?foo". + // Path, this is everything following the host name, stopping at the query of + // ref delimiter (if any). Length will be -1 if unspecified. This includes + // the preceeding slash, so the path on http://www.google.com/asdf" is + // "/asdf". As a result, it is impossible to have a 0 length path, it will + // be -1 in cases like "http://host?foo". // Note that we treat backslashes the same as slashes. Component path; @@ -177,6 +178,12 @@ struct URL_EXPORT Parsed { // nothing follows it. Component ref; + // The URL spec from the character after the scheme: until the end of the + // URL, regardless of the scheme. This is mostly useful for 'opaque' non- + // hierarchical schemes like data: and javascript: as a convient way to get + // the string with the scheme stripped off. + Component GetContent() const; + // This is used for nested URL types, currently only filesystem. If you // parse a filesystem URL, the resulting Parsed will have a nested // inner_parsed_ to hold the parsed inner URL's component information. |