| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 CharsetConverter* charset_converter, | 192 CharsetConverter* charset_converter, |
| 193 CanonOutput* output, | 193 CanonOutput* output, |
| 194 Parsed* output_parsed) { | 194 Parsed* output_parsed) { |
| 195 // Reserve enough room in the output for the input, plus some extra so that | 195 // Reserve enough room in the output for the input, plus some extra so that |
| 196 // we have room if we have to escape a few things without reallocating. | 196 // we have room if we have to escape a few things without reallocating. |
| 197 output->ReserveSizeIfNeeded(spec_len + 8); | 197 output->ReserveSizeIfNeeded(spec_len + 8); |
| 198 | 198 |
| 199 // Remove any whitespace from the middle of the relative URL if necessary. | 199 // Remove any whitespace from the middle of the relative URL if necessary. |
| 200 // Possibly this will result in copying to the new buffer. | 200 // Possibly this will result in copying to the new buffer. |
| 201 RawCanonOutputT<CHAR> whitespace_buffer; | 201 RawCanonOutputT<CHAR> whitespace_buffer; |
| 202 if (whitespace_policy == REMOVE_WHITESPACE) | 202 if (whitespace_policy == REMOVE_WHITESPACE) { |
| 203 spec = RemoveURLWhitespace(spec, spec_len, &whitespace_buffer, &spec_len); | 203 int original_len = spec_len; |
| 204 spec = |
| 205 RemoveURLWhitespace(spec, original_len, &whitespace_buffer, &spec_len); |
| 206 if (spec_len != original_len) |
| 207 output_parsed->whitespace_removed = true; |
| 208 } |
| 204 | 209 |
| 205 Parsed parsed_input; | 210 Parsed parsed_input; |
| 206 #ifdef WIN32 | 211 #ifdef WIN32 |
| 207 // For Windows, we allow things that look like absolute Windows paths to be | 212 // For Windows, we allow things that look like absolute Windows paths to be |
| 208 // fixed up magically to file URLs. This is done for IE compatibility. For | 213 // fixed up magically to file URLs. This is done for IE compatibility. For |
| 209 // example, this will change "c:/foo" into a file URL rather than treating | 214 // example, this will change "c:/foo" into a file URL rather than treating |
| 210 // it as a URL with the protocol "c". It also works for UNC ("\\foo\bar.txt"). | 215 // it as a URL with the protocol "c". It also works for UNC ("\\foo\bar.txt"). |
| 211 // There is similar logic in url_canon_relative.cc for | 216 // There is similar logic in url_canon_relative.cc for |
| 212 // | 217 // |
| 213 // For Max & Unix, we don't do this (the equivalent would be "/foo/bar" which | 218 // For Max & Unix, we don't do this (the equivalent would be "/foo/bar" which |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 CharsetConverter* charset_converter, | 278 CharsetConverter* charset_converter, |
| 274 CanonOutput* output, | 279 CanonOutput* output, |
| 275 Parsed* output_parsed) { | 280 Parsed* output_parsed) { |
| 276 // Remove any whitespace from the middle of the relative URL, possibly | 281 // Remove any whitespace from the middle of the relative URL, possibly |
| 277 // copying to the new buffer. | 282 // copying to the new buffer. |
| 278 RawCanonOutputT<CHAR> whitespace_buffer; | 283 RawCanonOutputT<CHAR> whitespace_buffer; |
| 279 int relative_length; | 284 int relative_length; |
| 280 const CHAR* relative = RemoveURLWhitespace(in_relative, in_relative_length, | 285 const CHAR* relative = RemoveURLWhitespace(in_relative, in_relative_length, |
| 281 &whitespace_buffer, | 286 &whitespace_buffer, |
| 282 &relative_length); | 287 &relative_length); |
| 288 if (in_relative_length != relative_length) |
| 289 output_parsed->whitespace_removed = true; |
| 290 |
| 283 bool base_is_authority_based = false; | 291 bool base_is_authority_based = false; |
| 284 bool base_is_hierarchical = false; | 292 bool base_is_hierarchical = false; |
| 285 if (base_spec && | 293 if (base_spec && |
| 286 base_parsed.scheme.is_nonempty()) { | 294 base_parsed.scheme.is_nonempty()) { |
| 287 int after_scheme = base_parsed.scheme.end() + 1; // Skip past the colon. | 295 int after_scheme = base_parsed.scheme.end() + 1; // Skip past the colon. |
| 288 int num_slashes = CountConsecutiveSlashes(base_spec, after_scheme, | 296 int num_slashes = CountConsecutiveSlashes(base_spec, after_scheme, |
| 289 base_spec_len); | 297 base_spec_len); |
| 290 base_is_authority_based = num_slashes > 1; | 298 base_is_authority_based = num_slashes > 1; |
| 291 base_is_hierarchical = num_slashes > 0; | 299 base_is_hierarchical = num_slashes > 0; |
| 292 } | 300 } |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 return DoCompareSchemeComponent(spec, component, compare_to); | 801 return DoCompareSchemeComponent(spec, component, compare_to); |
| 794 } | 802 } |
| 795 | 803 |
| 796 bool CompareSchemeComponent(const base::char16* spec, | 804 bool CompareSchemeComponent(const base::char16* spec, |
| 797 const Component& component, | 805 const Component& component, |
| 798 const char* compare_to) { | 806 const char* compare_to) { |
| 799 return DoCompareSchemeComponent(spec, component, compare_to); | 807 return DoCompareSchemeComponent(spec, component, compare_to); |
| 800 } | 808 } |
| 801 | 809 |
| 802 } // namespace url | 810 } // namespace url |
| OLD | NEW |