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

Unified Diff: chrome/common/net/x509_certificate_model.cc

Issue 23642003: Support IDNA 2008 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 | « no previous file | net/base/net_util.cc » ('j') | url/url_canon_icu.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/net/x509_certificate_model.cc
===================================================================
--- chrome/common/net/x509_certificate_model.cc (revision 215936)
+++ chrome/common/net/x509_certificate_model.cc (working copy)
@@ -21,20 +21,34 @@
string16 output16;
output16.resize(input.length());
+ // TODO(jungshik): Is this called from multiple threads?
+ static UIDNA* uidna = NULL; // will be leaked.
+ if (uidna == NULL) {
+ UErrorCode status = U_ZERO_ERROR;
+ // TODO(jungshik) : Review and change options as different
+ // parties (browsers, registrars, search engines) converge toward
+ // a consensus. Below is the most compatible with IDNA 2003 we used to use.
+ int32_t options = UIDNA_CHECK_BIDI;
+ uidna = uidna_openUTS46(options, &status);
+ if (U_FAILURE(status))
+ return input;
+ }
+
UErrorCode status = U_ZERO_ERROR;
- int output_chars = uidna_IDNToUnicode(input16.data(), input.length(),
- &output16[0], output16.length(),
- UIDNA_DEFAULT, NULL, &status);
- if (status == U_ZERO_ERROR) {
+ UIDNAInfo idna_info = UIDNA_INFO_INITIALIZER;
+ int output_chars = uidna_nameToUnicode(uidna, input16.data(), input.length(),
+ &output16[0], output16.length(),
+ &idna_info, &status);
+ if (U_SUCCESS(status) && idna_info.errors == 0) {
output16.resize(output_chars);
- } else if (status != U_BUFFER_OVERFLOW_ERROR) {
+ } else if (status != U_BUFFER_OVERFLOW_ERROR || idna_info.errors != 0) {
return input;
} else {
output16.resize(output_chars);
- output_chars = uidna_IDNToUnicode(input16.data(), input.length(),
- &output16[0], output16.length(),
- UIDNA_DEFAULT, NULL, &status);
- if (status != U_ZERO_ERROR)
+ output_chars = uidna_nameToUnicode(uidna, input16.data(), input.length(),
+ &output16[0], output16.length(),
+ &idna_info, &status);
+ if (U_FAILURE(status) || idna_info.errors != 0)
return input;
DCHECK_EQ(static_cast<size_t>(output_chars), output16.length());
output16.resize(output_chars); // Just to be safe.
@@ -89,5 +103,5 @@
}
#endif // USE_NSS
-} // x509_certificate_model
+} // namespace x509_certificate_model
« no previous file with comments | « no previous file | net/base/net_util.cc » ('j') | url/url_canon_icu.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698