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 #ifndef URL_URL_CANON_H_ | 5 #ifndef URL_URL_CANON_H_ |
6 #define URL_URL_CANON_H_ | 6 #define URL_URL_CANON_H_ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 // definition of CanonHostInfo above for details. | 372 // definition of CanonHostInfo above for details. |
373 URL_EXPORT void CanonicalizeHostVerbose(const char* spec, | 373 URL_EXPORT void CanonicalizeHostVerbose(const char* spec, |
374 const Component& host, | 374 const Component& host, |
375 CanonOutput* output, | 375 CanonOutput* output, |
376 CanonHostInfo* host_info); | 376 CanonHostInfo* host_info); |
377 URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec, | 377 URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec, |
378 const Component& host, | 378 const Component& host, |
379 CanonOutput* output, | 379 CanonOutput* output, |
380 CanonHostInfo* host_info); | 380 CanonHostInfo* host_info); |
381 | 381 |
382 // Canonicalizes a string according to the host canonicalization rules. Unlike | |
383 // CanonicalizeHost, this will not check for IP addresses which can change the | |
384 // meaning (and canonicalization) of the components. This means it is possible | |
385 // to call this for sub-components of a host name without corruption. | |
386 // | |
387 // As an example, "01.02.03.04.com" is a canonical hostname. If you called | |
388 // CanonicalizeHost on the substring "01.02.03.04" it will get "fixed" to | |
389 // "1.2.3.4" which will produce an invalid host name when reassembled. This | |
390 // is more common because all numbers by themselves are considered IP | |
Peter Kasting
2016/10/22 05:04:20
Nit: "more common" than what? More common than on
Peter Kasting
2016/10/25 01:33:32
(Still confused about this)
brettw
2016/10/25 20:28:17
Done.
| |
391 // addresses, so "5" canonicalizes to "0.0.0.5". | |
392 // | |
393 // Be careful, unless the input is guaranteed ASCII, it's not possible to split | |
Peter Kasting
2016/10/22 05:04:20
Nit: first comma -> semicolon
| |
394 // host names on anything but "." because Punycode works on each dot-separated | |
395 // substring as a unit. | |
Peter Kasting
2016/10/22 05:04:20
Nit: Maybe this paragraph should be more direct: "
brettw
2016/10/24 21:45:24
I mostly did your comment with some addition.
| |
396 // | |
397 // Returns true if the host was valid. This function will treat a 0-length | |
398 // host as valid (because it's designed to be used for substrings) while the | |
399 // full version above will mark empty hosts as broken. | |
400 URL_EXPORT bool CanonicalizeHostSubstring(const char* spec, | |
401 const Component& host, | |
402 CanonOutput* output); | |
403 URL_EXPORT bool CanonicalizeHostSubstring(const base::char16* spec, | |
404 const Component& host, | |
405 CanonOutput* output); | |
406 | |
382 // IP addresses. | 407 // IP addresses. |
383 // | 408 // |
384 // Tries to interpret the given host name as an IPv4 or IPv6 address. If it is | 409 // Tries to interpret the given host name as an IPv4 or IPv6 address. If it is |
385 // an IP address, it will canonicalize it as such, appending it to |output|. | 410 // an IP address, it will canonicalize it as such, appending it to |output|. |
386 // Additional status information is returned via the |*host_info| parameter. | 411 // Additional status information is returned via the |*host_info| parameter. |
387 // See the definition of CanonHostInfo above for details. | 412 // See the definition of CanonHostInfo above for details. |
388 // | 413 // |
389 // This is called AUTOMATICALLY from the host canonicalizer, which ensures that | 414 // This is called AUTOMATICALLY from the host canonicalizer, which ensures that |
390 // the input is unescaped and name-prepped, etc. It should not normally be | 415 // the input is unescaped and name-prepped, etc. It should not normally be |
391 // necessary or wise to call this directly. | 416 // necessary or wise to call this directly. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 bool base_is_file, | 908 bool base_is_file, |
884 const base::char16* relative_url, | 909 const base::char16* relative_url, |
885 const Component& relative_component, | 910 const Component& relative_component, |
886 CharsetConverter* query_converter, | 911 CharsetConverter* query_converter, |
887 CanonOutput* output, | 912 CanonOutput* output, |
888 Parsed* out_parsed); | 913 Parsed* out_parsed); |
889 | 914 |
890 } // namespace url | 915 } // namespace url |
891 | 916 |
892 #endif // URL_URL_CANON_H_ | 917 #endif // URL_URL_CANON_H_ |
OLD | NEW |