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

Side by Side Diff: url/url_util.cc

Issue 767713002: DoResolveRelative must not parse mailto schemes as path URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Next attempt Created 6 years 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
« no previous file with comments | « no previous file | url/url_util_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 #include "url/url_util.h" 5 #include "url/url_util.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return false; 231 return false;
232 } 232 }
233 233
234 // Pretend for a moment that |base_spec| is a standard URL. Normally 234 // Pretend for a moment that |base_spec| is a standard URL. Normally
235 // non-standard URLs are treated as PathURLs, but if the base has an 235 // non-standard URLs are treated as PathURLs, but if the base has an
236 // authority we would like to preserve it. 236 // authority we would like to preserve it.
237 if (is_relative && base_is_authority_based && !standard_base_scheme) { 237 if (is_relative && base_is_authority_based && !standard_base_scheme) {
238 Parsed base_parsed_authority; 238 Parsed base_parsed_authority;
239 ParseStandardURL(base_spec, base_spec_len, &base_parsed_authority); 239 ParseStandardURL(base_spec, base_spec_len, &base_parsed_authority);
240 if (base_parsed_authority.host.is_nonempty()) { 240 if (base_parsed_authority.host.is_nonempty()) {
241 RawCanonOutputT<char> temporary_output;
241 bool did_resolve_succeed = 242 bool did_resolve_succeed =
242 ResolveRelativeURL(base_spec, base_parsed_authority, false, relative, 243 ResolveRelativeURL(base_spec, base_parsed_authority, false, relative,
243 relative_component, charset_converter, output, 244 relative_component, charset_converter,
244 output_parsed); 245 &temporary_output, output_parsed);
245 // The output_parsed is incorrect at this point (because it was built 246 // The output_parsed is incorrect at this point (because it was built
246 // based on base_parsed_authority instead of base_parsed) and needs to be 247 // based on base_parsed_authority instead of base_parsed) and needs to be
247 // re-created. 248 // re-created.
248 ParsePathURL(output->data(), output->length(), true, 249 DoCanonicalize(temporary_output.data(), temporary_output.length(), true,
249 output_parsed); 250 charset_converter, output, output_parsed);
250 return did_resolve_succeed; 251 return did_resolve_succeed;
251 } 252 }
252 } else if (is_relative) { 253 } else if (is_relative) {
253 // Relative, resolve and canonicalize. 254 // Relative, resolve and canonicalize.
254 bool file_base_scheme = base_parsed.scheme.is_nonempty() && 255 bool file_base_scheme = base_parsed.scheme.is_nonempty() &&
255 DoCompareSchemeComponent(base_spec, base_parsed.scheme, kFileScheme); 256 DoCompareSchemeComponent(base_spec, base_parsed.scheme, kFileScheme);
256 return ResolveRelativeURL(base_spec, base_parsed, file_base_scheme, relative , 257 return ResolveRelativeURL(base_spec, base_parsed, file_base_scheme, relative ,
257 relative_component, charset_converter, output, 258 relative_component, charset_converter, output,
258 output_parsed); 259 output_parsed);
259 } 260 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 return DoCompareSchemeComponent(spec, component, compare_to); 577 return DoCompareSchemeComponent(spec, component, compare_to);
577 } 578 }
578 579
579 bool CompareSchemeComponent(const base::char16* spec, 580 bool CompareSchemeComponent(const base::char16* spec,
580 const Component& component, 581 const Component& component,
581 const char* compare_to) { 582 const char* compare_to) {
582 return DoCompareSchemeComponent(spec, component, compare_to); 583 return DoCompareSchemeComponent(spec, component, compare_to);
583 } 584 }
584 585
585 } // namespace url 586 } // namespace url
OLDNEW
« no previous file with comments | « no previous file | url/url_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698