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

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

Issue 1167793003: Escape all of invalid values in console messages for INPUT elements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | « Source/core/html/forms/DateInputType.cpp ('k') | Source/core/html/forms/TimeInputType.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/forms/EmailInputType.cpp
diff --git a/Source/core/html/forms/EmailInputType.cpp b/Source/core/html/forms/EmailInputType.cpp
index 5fe92ff24d5072b1a408d06ed0d6fbf3a00fc31e..db450d9faf26a52556de64578293530ae7e27971 100644
--- a/Source/core/html/forms/EmailInputType.cpp
+++ b/Source/core/html/forms/EmailInputType.cpp
@@ -30,6 +30,7 @@
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/page/ChromeClient.h"
+#include "platform/JSONValues.h"
#include "platform/text/PlatformLocale.h"
#include "public/platform/Platform.h"
#include "wtf/PassOwnPtr.h"
@@ -237,27 +238,13 @@ String EmailInputType::typeMismatchText() const
return locale().queryString(WebLocalizedString::ValidationTypeMismatchForEmail);
}
-static String escapeNonASCII(const String& source)
-{
- StringBuilder builder;
- builder.reserveCapacity(source.length());
- for (unsigned i = 0; i < source.length(); ++i) {
- if (isASCIIPrintable(source[i])) {
- builder.append(source[i]);
- continue;
- }
- builder.append(String::format("\\u%04x", source[i]));
- }
- return builder.toString();
-}
-
void EmailInputType::warnIfValueIsInvalid(const String& value) const
{
String invalidAddress = findInvalidAddress(value);
if (invalidAddress.isNull())
return;
element().document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, WarningMessageLevel,
- String::format("The specified value '%s' is not a valid email address.", escapeNonASCII(invalidAddress).utf8().data())));
+ String::format("The specified value %s is not a valid email address.", JSONValue::quoteString(invalidAddress).utf8().data())));
}
bool EmailInputType::supportsSelectionAPI() const
« no previous file with comments | « Source/core/html/forms/DateInputType.cpp ('k') | Source/core/html/forms/TimeInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698