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

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 1594039: Trim whitespace and check for unsafe scheme before adding a url in context me... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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: chrome/browser/tab_contents/render_view_context_menu.cc
===================================================================
--- chrome/browser/tab_contents/render_view_context_menu.cc (revision 44817)
+++ chrome/browser/tab_contents/render_view_context_menu.cc (working copy)
@@ -11,9 +11,11 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_manager.h"
@@ -439,6 +441,8 @@
void RenderViewContextMenu::AppendSearchProvider() {
DCHECK(profile_);
+ TrimWhitespace(params_.selection_text, TRIM_ALL, &params_.selection_text);
+
Peter Kasting 2010/04/20 18:25:32 Nit: You could probably remove this blank line.
if (params_.selection_text.empty())
return;
@@ -456,9 +460,12 @@
printable_selection_text.insert(i, 1, '&');
if (match.transition == PageTransition::TYPED) {
- AppendMenuItem(IDS_CONTENT_CONTEXT_GOTOURL,
- l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL,
- printable_selection_text));
+ if (ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
+ selection_navigation_url_.scheme())) {
+ AppendMenuItem(IDS_CONTENT_CONTEXT_GOTOURL,
+ l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL,
+ printable_selection_text));
+ }
} else {
const TemplateURL* const default_provider =
profile_->GetTemplateURLModel()->GetDefaultSearchProvider();
« 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