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 // can happen more than one might think because all numbers by themselves are | |
391 // considered IP addresses; so "5" canonicalizes to "0.0.0.5". | |
392 // | |
393 // Be careful: Because Punycode works on each dot-separated substring as a | |
394 // unit, you should only pass this function substrings that represent complete | |
395 // dot-separated subcomponents of the original host. Even if you have ASCII | |
396 // input, percent-escaped characters will have different meanings if split in | |
397 // the middle. | |
398 // | |
399 // Returns true if the host was valid. This function will treat a 0-length | |
400 // host as valid (because it's designed to be used for substrings) while the | |
401 // full version above will mark empty hosts as broken. | |
402 URL_EXPORT bool CanonicalizeHostSubstring(const char* spec, | |
403 const Component& host, | |
404 CanonOutput* output); | |
405 URL_EXPORT bool CanonicalizeHostSubstring(const base::char16* spec, | |
406 const Component& host, | |
407 CanonOutput* output); | |
408 | |
409 // IP addresses. | 382 // IP addresses. |
410 // | 383 // |
411 // Tries to interpret the given host name as an IPv4 or IPv6 address. If it is | 384 // Tries to interpret the given host name as an IPv4 or IPv6 address. If it is |
412 // an IP address, it will canonicalize it as such, appending it to |output|. | 385 // an IP address, it will canonicalize it as such, appending it to |output|. |
413 // Additional status information is returned via the |*host_info| parameter. | 386 // Additional status information is returned via the |*host_info| parameter. |
414 // See the definition of CanonHostInfo above for details. | 387 // See the definition of CanonHostInfo above for details. |
415 // | 388 // |
416 // This is called AUTOMATICALLY from the host canonicalizer, which ensures that | 389 // This is called AUTOMATICALLY from the host canonicalizer, which ensures that |
417 // the input is unescaped and name-prepped, etc. It should not normally be | 390 // the input is unescaped and name-prepped, etc. It should not normally be |
418 // necessary or wise to call this directly. | 391 // necessary or wise to call this directly. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 bool base_is_file, | 883 bool base_is_file, |
911 const base::char16* relative_url, | 884 const base::char16* relative_url, |
912 const Component& relative_component, | 885 const Component& relative_component, |
913 CharsetConverter* query_converter, | 886 CharsetConverter* query_converter, |
914 CanonOutput* output, | 887 CanonOutput* output, |
915 Parsed* out_parsed); | 888 Parsed* out_parsed); |
916 | 889 |
917 } // namespace url | 890 } // namespace url |
918 | 891 |
919 #endif // URL_URL_CANON_H_ | 892 #endif // URL_URL_CANON_H_ |
OLD | NEW |