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

Unified Diff: url/url_canon.h

Issue 2446273004: Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: Review comment Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/public/platform/WebPublicSuffixList.h ('k') | url/url_canon_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_canon.h
diff --git a/url/url_canon.h b/url/url_canon.h
index 95d53453f64362efc98d8141c11691573eaae165..c4852e490b05b0286b463ab23eca0c238eeec52a 100644
--- a/url/url_canon.h
+++ b/url/url_canon.h
@@ -379,6 +379,33 @@ URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec,
CanonOutput* output,
CanonHostInfo* host_info);
+// Canonicalizes a string according to the host canonicalization rules. Unlike
+// CanonicalizeHost, this will not check for IP addresses which can change the
+// meaning (and canonicalization) of the components. This means it is possible
+// to call this for sub-components of a host name without corruption.
+//
+// As an example, "01.02.03.04.com" is a canonical hostname. If you called
+// CanonicalizeHost on the substring "01.02.03.04" it will get "fixed" to
+// "1.2.3.4" which will produce an invalid host name when reassembled. This
+// can happen more than one might think because all numbers by themselves are
+// considered IP addresses; so "5" canonicalizes to "0.0.0.5".
+//
+// Be careful: Because Punycode works on each dot-separated substring as a
+// unit, you should only pass this function substrings that represent complete
+// dot-separated subcomponents of the original host. Even if you have ASCII
+// input, percent-escaped characters will have different meanings if split in
+// the middle.
+//
+// Returns true if the host was valid. This function will treat a 0-length
+// host as valid (because it's designed to be used for substrings) while the
+// full version above will mark empty hosts as broken.
+URL_EXPORT bool CanonicalizeHostSubstring(const char* spec,
+ const Component& host,
+ CanonOutput* output);
+URL_EXPORT bool CanonicalizeHostSubstring(const base::char16* spec,
+ const Component& host,
+ CanonOutput* output);
+
// IP addresses.
//
// Tries to interpret the given host name as an IPv4 or IPv6 address. If it is
« no previous file with comments | « third_party/WebKit/public/platform/WebPublicSuffixList.h ('k') | url/url_canon_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698