summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing
diff options
context:
space:
mode:
authorinferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-02 14:35:48 +0000
committerinferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-02 14:35:48 +0000
commit14aab33b970082e517fdd9654de0e9d32392cc54 (patch)
treec48c92501be1af916b73232d2a91f5fe15c94e36 /chrome/browser/safe_browsing
parentada0620df1945dc5d60828dde5ce4f81a43718f5 (diff)
downloadchromium_src-14aab33b970082e517fdd9654de0e9d32392cc54.zip
chromium_src-14aab33b970082e517fdd9654de0e9d32392cc54.tar.gz
chromium_src-14aab33b970082e517fdd9654de0e9d32392cc54.tar.bz2
Add ftp protocol to the safebrowsing checks. Fixed the crash with canonicalization of non-standard urls in CanonicalizeUrl function. Add CanCheckUrl to a more central location. Added the null check in GeneratePathsToCheck. Remove redundant checks from resource dispatcher host.
BUG=40605 TEST=SafeBrowsingUtilTest.CanonicalizeUrl Review URL: http://codereview.chromium.org/2471002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.cc8
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util_unittest.cc20
3 files changed, 32 insertions, 2 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index ede1587..7999296 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -60,7 +60,8 @@ void SafeBrowsingService::ShutDown() {
}
bool SafeBrowsingService::CanCheckUrl(const GURL& url) const {
- return url.SchemeIs(chrome::kHttpScheme) ||
+ return url.SchemeIs(chrome::kFtpScheme) ||
+ url.SchemeIs(chrome::kHttpScheme) ||
url.SchemeIs(chrome::kHttpsScheme);
}
@@ -69,6 +70,9 @@ bool SafeBrowsingService::CheckUrl(const GURL& url, Client* client) {
if (!enabled_)
return true;
+ if (!CanCheckUrl(url))
+ return true;
+
if (!MakeDatabaseAvailable()) {
QueuedCheck check;
check.client = client;
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index 3fa3a27..80c3d3ad 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -214,6 +214,12 @@ void CanonicalizeUrl(const GURL& url,
std::string* canonicalized_hostname,
std::string* canonicalized_path,
std::string* canonicalized_query) {
+ DCHECK(url.is_valid());
+
+ // We only canonicalize "normal" URLs.
+ if (!url.IsStandard())
+ return;
+
// Following canonicalization steps are excluded since url parsing takes care
// of those :-
// 1. Remove any tab (0x09), CR (0x0d), and LF (0x0a) chars from url.
@@ -354,7 +360,7 @@ void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths) {
paths->push_back(std::string(path.begin(), i + 1));
}
- if (paths->back() != path)
+ if (!paths->empty() && paths->back() != path)
paths->push_back(path);
if (!query.empty())
diff --git a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
index d74982c..5204bfe 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
@@ -239,6 +239,26 @@ TEST(SafeBrowsingUtilTest, CanonicalizeUrl) {
"host.com",
"/abc/def/xyz",
""
+ }, {
+ "ftp://host.com/foo?bar",
+ "host.com",
+ "/foo",
+ "bar"
+ }, {
+ "data:text/html;charset=utf-8,%0D%0A",
+ "",
+ "",
+ ""
+ }, {
+ "javascript:alert()",
+ "",
+ "",
+ ""
+ }, {
+ "mailto:abc@example.com",
+ "",
+ "",
+ ""
},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {