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

Unified Diff: third_party/WebKit/Source/core/html/forms/EmailInputType.cpp

Issue 1408833006: EmailInputType::convertEmailAddressToASCII() should not try to convert non-email addresses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use isValidEmailAddress() instead of ad-hoc check Created 5 years, 1 month 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 | third_party/WebKit/Source/core/html/forms/EmailInputTypeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/forms/EmailInputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/EmailInputType.cpp b/third_party/WebKit/Source/core/html/forms/EmailInputType.cpp
index 384339ccacd499fd7dac54912e91a719db9c6019..3a0865e7280501aaf1252ee73ad7dcd79a6b9df9 100644
--- a/third_party/WebKit/Source/core/html/forms/EmailInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/EmailInputType.cpp
@@ -64,11 +64,12 @@ String EmailInputType::convertEmailAddressToASCII(const String& address)
size_t atPosition = address.find('@');
if (atPosition == kNotFound)
return address;
+ String host = address.substring(atPosition + 1);
// UnicodeString ctor for copy-on-write does not work reliably (in debug
// build.) TODO(jshin): In an unlikely case this is a perf-issue, treat
// 8bit and non-8bit strings separately.
- icu::UnicodeString idnDomainName(address.charactersWithNullTermination().data() + atPosition + 1, address.length() - atPosition - 1);
+ icu::UnicodeString idnDomainName(host.charactersWithNullTermination().data(), host.length());
icu::UnicodeString domainName;
// Leak |idna| at the end.
@@ -83,7 +84,8 @@ String EmailInputType::convertEmailAddressToASCII(const String& address)
StringBuilder builder;
builder.append(address, 0, atPosition + 1);
builder.append(domainName.getBuffer(), domainName.length());
- return builder.toString();
+ String asciiEmail = builder.toString();
+ return isValidEmailAddress(asciiEmail) ? asciiEmail : address;
}
String EmailInputType::convertEmailAddressToUnicode(const String& address) const
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/forms/EmailInputTypeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698