summaryrefslogtreecommitdiffstats
path: root/url/url_canon_relative.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 01:53:52 +0000
commit369e84f70d256d188a1866d8cef52edf4468cd9b (patch)
treee7e90408125f4831ce7983fd37414ad763b965b1 /url/url_canon_relative.cc
parenta7e3691579181327dc65b02d043e7c01d4b06cb9 (diff)
downloadchromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.zip
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.gz
chromium_src-369e84f70d256d188a1866d8cef52edf4468cd9b.tar.bz2
Support URL fragment resolution against non-hierarchical schemes
Support URL fragment resolution against non-hierarchical schemes As a result, data: about: etc now have 'query' and 'ref' components parsed; as a result a new GURL::GetContent() convenience is added to retrieve the spec with the scheme stripped off. A complication in supporting this is that we now need to allow whitespace to trailing whitespace to be preserved when transferring url_parse::Parsed structs between KURL and GURL. Without this, the URL prior to the #fragment can change (i.e. whitespace stripped) when following an anchor link which breaks the page (causes reload from source). See http://crbug.com/291747 for more details on this. R=brettw@chromium.org TBR=cbentzel@chromium.org BUG=291747 Review URL: https://codereview.chromium.org/23835019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url/url_canon_relative.cc')
-rw-r--r--url/url_canon_relative.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/url/url_canon_relative.cc b/url/url_canon_relative.cc
index 4edd6ced..33b814c 100644
--- a/url/url_canon_relative.cc
+++ b/url/url_canon_relative.cc
@@ -101,10 +101,16 @@ bool DoIsRelativeURL(const char* base,
// "http:foo.html" is a relative URL with path "foo.html". If the scheme is
// empty, we treat it as relative (":foo") like IE does.
url_parse::Component scheme;
- if (!url_parse::ExtractScheme(url, url_len, &scheme) || scheme.len == 0) {
- // Don't allow relative URLs if the base scheme doesn't support it.
- if (!is_base_hierarchical)
+ const bool scheme_is_empty =
+ !url_parse::ExtractScheme(url, url_len, &scheme) || scheme.len == 0;
+ if (scheme_is_empty) {
+ if (url[begin] == '#') {
+ // |url| is a bare fragement (e.g. "#foo"). This can be resolved against
+ // any base. Fall-through.
+ } else if (!is_base_hierarchical) {
+ // Don't allow relative URLs if the base scheme doesn't support it.
return false;
+ }
*relative_component = url_parse::MakeRange(begin, url_len);
*is_relative = true;