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

Unified Diff: chrome/browser/dom_ui/tips_handler.cc

Issue 149083: Validates links which are to be passed on to the NTP by ensuring that they st... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/browser/dom_ui/tips_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/tips_handler.cc
===================================================================
--- chrome/browser/dom_ui/tips_handler.cc (revision 19306)
+++ chrome/browser/dom_ui/tips_handler.cc (working copy)
@@ -7,8 +7,10 @@
#include "chrome/browser/dom_ui/tips_handler.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/web_resource/web_resource_service.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/web_resource/web_resource_unpacker.h"
-#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
+#include "googleurl/src/gurl.h"
namespace {
@@ -60,7 +62,8 @@
if (wr_dict &&
wr_dict->GetSize() > 0 &&
wr_dict->GetString(WebResourceService::kWebResourceTitle, &title) &&
- wr_dict->GetString(WebResourceService::kWebResourceURL, &url)) {
+ wr_dict->GetString(WebResourceService::kWebResourceURL, &url) &&
+ IsValidURL(url)) {
tip_dict->SetString(WebResourceService::kWebResourceTitle, title);
tip_dict->SetString(WebResourceService::kWebResourceURL, url);
list_value.Append(tip_dict);
@@ -79,4 +82,9 @@
WebResourceService::kDefaultResourceServer);
}
+bool TipsHandler::IsValidURL(const std::wstring& url_string) {
+ GURL url(WideToUTF8(url_string));
+ return !url.is_empty() && (url.SchemeIs(chrome::kHttpScheme) ||
+ url.SchemeIs(chrome::kHttpsScheme));
+}
« no previous file with comments | « chrome/browser/dom_ui/tips_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698