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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « url/url_canon_pathurl.cc ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Canonicalizer functions for working with and resolving relative URLs. 5 // Canonicalizer functions for working with and resolving relative URLs.
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "url/url_canon.h" 8 #include "url/url_canon.h"
9 #include "url/url_canon_internal.h" 9 #include "url/url_canon_internal.h"
10 #include "url/url_file.h" 10 #include "url/url_file.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (url_parse::DoesBeginWindowsDriveSpec(url, begin, url_len) || 94 if (url_parse::DoesBeginWindowsDriveSpec(url, begin, url_len) ||
95 url_parse::DoesBeginUNCPath(url, begin, url_len, true)) 95 url_parse::DoesBeginUNCPath(url, begin, url_len, true))
96 return true; 96 return true;
97 #endif // WIN32 97 #endif // WIN32
98 98
99 // See if we've got a scheme, if not, we know this is a relative URL. 99 // See if we've got a scheme, if not, we know this is a relative URL.
100 // BUT: Just because we have a scheme, doesn't make it absolute. 100 // BUT: Just because we have a scheme, doesn't make it absolute.
101 // "http:foo.html" is a relative URL with path "foo.html". If the scheme is 101 // "http:foo.html" is a relative URL with path "foo.html". If the scheme is
102 // empty, we treat it as relative (":foo") like IE does. 102 // empty, we treat it as relative (":foo") like IE does.
103 url_parse::Component scheme; 103 url_parse::Component scheme;
104 if (!url_parse::ExtractScheme(url, url_len, &scheme) || scheme.len == 0) { 104 const bool scheme_is_empty =
105 // Don't allow relative URLs if the base scheme doesn't support it. 105 !url_parse::ExtractScheme(url, url_len, &scheme) || scheme.len == 0;
106 if (!is_base_hierarchical) 106 if (scheme_is_empty) {
107 if (url[begin] == '#') {
108 // |url| is a bare fragement (e.g. "#foo"). This can be resolved against
109 // any base. Fall-through.
110 } else if (!is_base_hierarchical) {
111 // Don't allow relative URLs if the base scheme doesn't support it.
107 return false; 112 return false;
113 }
108 114
109 *relative_component = url_parse::MakeRange(begin, url_len); 115 *relative_component = url_parse::MakeRange(begin, url_len);
110 *is_relative = true; 116 *is_relative = true;
111 return true; 117 return true;
112 } 118 }
113 119
114 // If the scheme isn't valid, then it's relative. 120 // If the scheme isn't valid, then it's relative.
115 int scheme_end = scheme.end(); 121 int scheme_end = scheme.end();
116 for (int i = scheme.begin; i < scheme_end; i++) { 122 for (int i = scheme.begin; i < scheme_end; i++) {
117 if (!CanonicalSchemeChar(url[i])) { 123 if (!CanonicalSchemeChar(url[i])) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 const url_parse::Component& relative_component, 553 const url_parse::Component& relative_component,
548 CharsetConverter* query_converter, 554 CharsetConverter* query_converter,
549 CanonOutput* output, 555 CanonOutput* output,
550 url_parse::Parsed* out_parsed) { 556 url_parse::Parsed* out_parsed) {
551 return DoResolveRelativeURL<base::char16>( 557 return DoResolveRelativeURL<base::char16>(
552 base_url, base_parsed, base_is_file, relative_url, 558 base_url, base_parsed, base_is_file, relative_url,
553 relative_component, query_converter, output, out_parsed); 559 relative_component, query_converter, output, out_parsed);
554 } 560 }
555 561
556 } // namespace url_canon 562 } // namespace url_canon
OLDNEW
« 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