OLD | NEW |
---|---|
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bool did_resolve_succeed = | 241 bool did_resolve_succeed = |
242 ResolveRelativeURL(base_spec, base_parsed_authority, false, relative, | 242 ResolveRelativeURL(base_spec, base_parsed_authority, false, relative, |
brettw
2014/12/01 20:15:09
This should write into your temporary buffer rathe
| |
243 relative_component, charset_converter, output, | 243 relative_component, charset_converter, output, |
244 output_parsed); | 244 output_parsed); |
245 // The output_parsed is incorrect at this point (because it was built | 245 // 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 | 246 // based on base_parsed_authority instead of base_parsed) and needs to be |
247 // re-created. | 247 // re-created. |
248 ParsePathURL(output->data(), output->length(), true, | 248 RawCanonOutputT<char> full_spec; |
249 output_parsed); | 249 full_spec.Append(output->data(), output->length()); |
250 output->set_length(0); | |
251 DoCanonicalize(full_spec.data(), full_spec.length(), true, | |
252 charset_converter, output, output_parsed); | |
250 return did_resolve_succeed; | 253 return did_resolve_succeed; |
251 } | 254 } |
252 } else if (is_relative) { | 255 } else if (is_relative) { |
253 // Relative, resolve and canonicalize. | 256 // Relative, resolve and canonicalize. |
254 bool file_base_scheme = base_parsed.scheme.is_nonempty() && | 257 bool file_base_scheme = base_parsed.scheme.is_nonempty() && |
255 DoCompareSchemeComponent(base_spec, base_parsed.scheme, kFileScheme); | 258 DoCompareSchemeComponent(base_spec, base_parsed.scheme, kFileScheme); |
256 return ResolveRelativeURL(base_spec, base_parsed, file_base_scheme, relative , | 259 return ResolveRelativeURL(base_spec, base_parsed, file_base_scheme, relative , |
257 relative_component, charset_converter, output, | 260 relative_component, charset_converter, output, |
258 output_parsed); | 261 output_parsed); |
259 } | 262 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 return DoCompareSchemeComponent(spec, component, compare_to); | 579 return DoCompareSchemeComponent(spec, component, compare_to); |
577 } | 580 } |
578 | 581 |
579 bool CompareSchemeComponent(const base::char16* spec, | 582 bool CompareSchemeComponent(const base::char16* spec, |
580 const Component& component, | 583 const Component& component, |
581 const char* compare_to) { | 584 const char* compare_to) { |
582 return DoCompareSchemeComponent(spec, component, compare_to); | 585 return DoCompareSchemeComponent(spec, component, compare_to); |
583 } | 586 } |
584 | 587 |
585 } // namespace url | 588 } // namespace url |
OLD | NEW |