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

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: Rebase 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..d80087eee5a20e0d283812c880571d2d99a7822c 100644
--- a/Source/core/inspector/InspectorFrontendHost.cpp
+++ b/Source/core/inspector/InspectorFrontendHost.cpp
@@ -160,16 +160,33 @@ void InspectorFrontendHost::copyText(const String& text)
Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmartReplace);
}
+static String escapeUnicodeNonCharacters(const String& str)
+{
+ StringBuilder dst;
+ for (unsigned i = 0; i < str.length(); ++i) {
+ UChar c = str[i];
+ if (c > 126) {
alph 2014/03/05 09:01:54 126 seems to be too conservative. I'd suggest esca
yurys 2014/03/05 11:33:37 PTAL: https://codereview.chromium.org/180113008/
+ 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::sendMessageToBackend(const String& message)
{
if (m_client)
- m_client->sendMessageToBackend(message);
+ m_client->sendMessageToBackend(escapeUnicodeNonCharacters(message));
}
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