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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void InspectorFrontendHost::setInjectedScriptForOrigin(const String& origin, con st String& script) 153 void InspectorFrontendHost::setInjectedScriptForOrigin(const String& origin, con st String& script)
154 { 154 {
155 m_frontendPage->inspectorController().setInjectedScriptForOrigin(origin, scr ipt); 155 m_frontendPage->inspectorController().setInjectedScriptForOrigin(origin, scr ipt);
156 } 156 }
157 157
158 void InspectorFrontendHost::copyText(const String& text) 158 void InspectorFrontendHost::copyText(const String& text)
159 { 159 {
160 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar tReplace); 160 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar tReplace);
161 } 161 }
162 162
163 static String escapeUnicodeNonCharacters(const String& str)
164 {
165 StringBuilder dst;
166 for (unsigned i = 0; i < str.length(); ++i) {
167 UChar c = str[i];
168 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/
169 unsigned symbol = static_cast<unsigned>(c);
170 String symbolCode = String::format("\\u%04X", symbol);
171 dst.append(symbolCode);
172 } else {
173 dst.append(c);
174 }
175
176 }
177 return dst.toString();
178 }
179
163 void InspectorFrontendHost::sendMessageToBackend(const String& message) 180 void InspectorFrontendHost::sendMessageToBackend(const String& message)
164 { 181 {
165 if (m_client) 182 if (m_client)
166 m_client->sendMessageToBackend(message); 183 m_client->sendMessageToBackend(escapeUnicodeNonCharacters(message));
167 } 184 }
168 185
169 void InspectorFrontendHost::sendMessageToEmbedder(const String& message) 186 void InspectorFrontendHost::sendMessageToEmbedder(const String& message)
170 { 187 {
171 if (m_client) 188 if (m_client)
172 m_client->sendMessageToEmbedder(message); 189 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message));
173 } 190 }
174 191
175 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items) 192 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items)
176 { 193 {
177 if (!event) 194 if (!event)
178 return; 195 return;
179 196
180 ASSERT(m_frontendPage); 197 ASSERT(m_frontendPage);
181 ScriptState* frontendScriptState = mainWorldScriptState(m_frontendPage->main Frame()); 198 ScriptState* frontendScriptState = mainWorldScriptState(m_frontendPage->main Frame());
182 ScriptObject frontendApiObject; 199 ScriptObject frontendApiObject;
(...skipping 15 matching lines...) Expand all
198 { 215 {
199 return RenderTheme::theme().activeSelectionForegroundColor().serialized(); 216 return RenderTheme::theme().activeSelectionForegroundColor().serialized();
200 } 217 }
201 218
202 bool InspectorFrontendHost::isUnderTest() 219 bool InspectorFrontendHost::isUnderTest()
203 { 220 {
204 return m_client && m_client->isUnderTest(); 221 return m_client && m_client->isUnderTest();
205 } 222 }
206 223
207 } // namespace WebCore 224 } // namespace WebCore
OLDNEW
« 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