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

Unified Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 8513002: Strip invalid characters (line breaks, tabs), javascript:schemes from the copied text before pasting (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc (revision 110486)
+++ chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc (working copy)
@@ -1444,7 +1444,9 @@
// back after shutdown, and similar issues.
GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
gchar* text = gtk_clipboard_wait_for_text(x_clipboard);
- string16 text_wstr = UTF8ToUTF16(text ? text : "");
+ string16 sanitized_text(text ?
+ CollapseWhitespace(StripJavascriptSchemas(UTF8ToUTF16(text)), true) :
Peter Kasting 2011/11/21 21:23:43 Why did you reverse the order of the calls here?
SanjoyPal 2011/11/22 07:02:14 Done.
+ string16());
g_free(text);
// Paste and Go menu item.
@@ -1456,7 +1458,7 @@
g_signal_connect(paste_go_menuitem, "activate",
G_CALLBACK(HandlePasteAndGoThunk), this);
gtk_widget_set_sensitive(paste_go_menuitem,
- model_->CanPasteAndGo(text_wstr));
+ model_->CanPasteAndGo(sanitized_text));
Peter Kasting 2011/11/21 21:23:43 Why did you move this call back down here since th
SanjoyPal 2011/11/22 07:02:14 Done.
gtk_widget_show(paste_go_menuitem);
g_signal_connect(menu, "deactivate",
@@ -1661,14 +1663,16 @@
p = next;
}
- if (filtered_text.length()) {
+ const std::string sanitized_text =
+ UTF16ToUTF8(StripJavascriptSchemas(UTF8ToUTF16(filtered_text)));
+ if (sanitized_text.length()) {
Peter Kasting 2011/11/21 21:23:43 Nit: Change to using !empty()
SanjoyPal 2011/11/22 07:02:14 Done.
// Avoid inserting the text after the instant anchor.
ValidateTextBufferIter(location);
// Call the default handler to insert filtered text.
GtkTextBufferClass* klass = GTK_TEXT_BUFFER_GET_CLASS(buffer);
- klass->insert_text(buffer, location, filtered_text.data(),
- static_cast<gint>(filtered_text.length()));
+ klass->insert_text(buffer, location, sanitized_text.data(),
+ static_cast<gint>(sanitized_text.length()));
}
// Stop propagating the signal emission to prevent the default handler from
« 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