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

Unified Diff: url/url_canon_relative.cc

Issue 23835019: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: brettw2 Created 7 years, 1 month 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 | « url/url_canon_pathurl.cc ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_canon_relative.cc
diff --git a/url/url_canon_relative.cc b/url/url_canon_relative.cc
index 4edd6cedd68beed6d068fee1958ceae40929f1db..33b814c0a998d04a9ac2291d3ac38d7f3b1e667d 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;
« no previous file with comments | « url/url_canon_pathurl.cc ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698