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

Unified Diff: Source/core/inspector/InspectorFrontendHost.cpp

Issue 178473027: Make sure string passed to sendMessageToEmbedder is a valid unicode string (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorFrontendHost.cpp
diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp
index 04d53529857bf85a59f12195c2651b3a24ce445f..2c0023898804d25599d66b08bc49a0af5a8a0a57 100644
--- a/Source/core/inspector/InspectorFrontendHost.cpp
+++ b/Source/core/inspector/InspectorFrontendHost.cpp
@@ -166,10 +166,27 @@ void InspectorFrontendHost::sendMessageToBackend(const String& message)
m_client->sendMessageToBackend(message);
pfeldman 2014/03/04 11:45:46 Lets use it here as well.
yurys 2014/03/04 12:15:35 Done.
}
+static String escapeUnicodeNonCharacters(const String& str)
+{
+ StringBuilder dst;
+ for (unsigned i = 0; i < str.length(); ++i) {
+ UChar c = str[i];
+ if (c < 32 || c > 126) {
+ unsigned symbol = static_cast<unsigned>(c);
+ String symbolCode = String::format("\\u%04X", symbol);
+ dst.append(symbolCode);
+ } else {
+ dst.append(c);
+ }
+
+ }
+ return dst.toString();
+}
+
void InspectorFrontendHost::sendMessageToEmbedder(const String& message)
{
if (m_client)
- m_client->sendMessageToEmbedder(message);
+ m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message));
}
void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMenuItem>& items)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698