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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 6982011: Strip leading "javascript:" schemas from text pasted or dropped into the omnibox. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc
===================================================================
--- chrome/browser/ui/views/omnibox/omnibox_view_win.cc (revision 85569)
+++ chrome/browser/ui/views/omnibox/omnibox_view_win.cc (working copy)
@@ -958,8 +958,10 @@
GURL url;
string16 title;
if (data.GetURLAndTitle(&url, &title)) {
- SetUserText(UTF8ToWide(url.spec()));
- model()->AcceptInput(CURRENT_TAB, true);
+ string16 text(views::StripJavascriptSchemas(UTF8ToUTF16(url.spec())));
+ SetUserText(text);
+ if (url.spec().length() == text.length())
+ model()->AcceptInput(CURRENT_TAB, true);
return CopyOrLinkDragOperation(event.source_operations());
}
} else if (data.HasString()) {
@@ -2356,14 +2358,14 @@
ui::Clipboard::BUFFER_STANDARD)) {
string16 text;
clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &text);
-
+ string16 stripped_text(views::StripJavascriptSchemas(text));
Peter Kasting 2011/05/24 00:15:18 Nit: Just inline this into the next statement
Cris Neckar 2011/05/24 17:09:40 Done.
// Note: Unlike in the find popup and textfield view, here we completely
// remove whitespace strings containing newlines. We assume users are
// most likely pasting in URLs that may have been split into multiple
// lines in terminals, email programs, etc., and so linebreaks indicate
// completely bogus whitespace that would just cause the input to be
// invalid.
- return CollapseWhitespace(text, true);
+ return CollapseWhitespace(stripped_text, true);
}
// Try bookmark format.
@@ -2380,7 +2382,7 @@
// pass resulting url string through GURL to normalize
GURL url(url_str);
if (url.is_valid())
- return UTF8ToWide(url.spec());
+ return views::StripJavascriptSchemas(UTF8ToUTF16(url.spec()));
}
return string16();

Powered by Google App Engine
This is Rietveld 408576698