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

Unified Diff: url/url_canon_host.cc

Issue 2454553002: Revert of Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: 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 | « url/url_canon.h ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_canon_host.cc
diff --git a/url/url_canon_host.cc b/url/url_canon_host.cc
index 76a22369b87648ce3651a94e4ca6aaa460224ac6..d4cdfd52bc566d3d4df295f80f5af3e630236e22 100644
--- a/url/url_canon_host.cc
+++ b/url/url_canon_host.cc
@@ -308,25 +308,7 @@
return DoIDNHost(host, host_len, output);
}
-template <typename CHAR, typename UCHAR>
-bool DoHostSubstring(const CHAR* spec,
- const Component& host,
- CanonOutput* output) {
- bool has_non_ascii, has_escaped;
- ScanHostname<CHAR, UCHAR>(spec, host, &has_non_ascii, &has_escaped);
-
- if (has_non_ascii || has_escaped) {
- return DoComplexHost(&spec[host.begin], host.len, has_non_ascii,
- has_escaped, output);
- }
-
- const bool success =
- DoSimpleHost(&spec[host.begin], host.len, output, &has_non_ascii);
- DCHECK(!has_non_ascii);
- return success;
-}
-
-template <typename CHAR, typename UCHAR>
+template<typename CHAR, typename UCHAR>
void DoHost(const CHAR* spec,
const Component& host,
CanonOutput* output,
@@ -338,10 +320,26 @@
return;
}
+ bool has_non_ascii, has_escaped;
+ ScanHostname<CHAR, UCHAR>(spec, host, &has_non_ascii, &has_escaped);
+
// Keep track of output's initial length, so we can rewind later.
const int output_begin = output->length();
- if (DoHostSubstring<CHAR, UCHAR>(spec, host, output)) {
+ bool success;
+ if (!has_non_ascii && !has_escaped) {
+ success = DoSimpleHost(&spec[host.begin], host.len,
+ output, &has_non_ascii);
+ DCHECK(!has_non_ascii);
+ } else {
+ success = DoComplexHost(&spec[host.begin], host.len,
+ has_non_ascii, has_escaped, output);
+ }
+
+ if (!success) {
+ // Canonicalization failed. Set BROKEN to notify the caller.
+ host_info->family = CanonHostInfo::BROKEN;
+ } else {
// After all the other canonicalization, check if we ended up with an IP
// address. IP addresses are small, so writing into this temporary buffer
// should not cause an allocation.
@@ -357,9 +355,6 @@
output->set_length(output_begin);
output->Append(canon_ip.data(), canon_ip.length());
}
- } else {
- // Canonicalization failed. Set BROKEN to notify the caller.
- host_info->family = CanonHostInfo::BROKEN;
}
host_info->out_host = MakeRange(output_begin, output->length());
@@ -401,16 +396,4 @@
DoHost<base::char16, base::char16>(spec, host, output, host_info);
}
-bool CanonicalizeHostSubstring(const char* spec,
- const Component& host,
- CanonOutput* output) {
- return DoHostSubstring<char, unsigned char>(spec, host, output);
-}
-
-bool CanonicalizeHostSubstring(const base::char16* spec,
- const Component& host,
- CanonOutput* output) {
- return DoHostSubstring<base::char16, base::char16>(spec, host, output);
-}
-
} // namespace url
« no previous file with comments | « url/url_canon.h ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698