diff options
author | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 01:36:16 +0000 |
---|---|---|
committer | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 01:36:16 +0000 |
commit | b4eec82cb56fdc664401b56843a575618dc0955f (patch) | |
tree | 3a42a3cd06866b7ddbcd80ed92d0e8d2f5cc7d64 | |
parent | 7cd915520247809d4cd48bc4c2a59531db593b45 (diff) | |
download | chromium_src-b4eec82cb56fdc664401b56843a575618dc0955f.zip chromium_src-b4eec82cb56fdc664401b56843a575618dc0955f.tar.gz chromium_src-b4eec82cb56fdc664401b56843a575618dc0955f.tar.bz2 |
Merge 95731 - Be a little more careful whether something is an URL or a file path.
BUG=72492
Review URL: http://codereview.chromium.org/7572046
TBR=cevans@chromium.org
Review URL: http://codereview.chromium.org/7602005
git-svn-id: svn://svn.chromium.org/chrome/branches/835/src@95929 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/url_fixer_upper.cc | 6 | ||||
-rw-r--r-- | chrome/browser/net/url_fixer_upper_unittest.cc | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 37125d0..4d85b42 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -538,8 +538,12 @@ GURL URLFixerUpper::FixupRelativeFile(const FilePath& base_dir, PrepareStringForFileOps(text, &trimmed); bool is_file = true; + // Avoid recognizing definite non-file URLs as file paths. + GURL gurl(trimmed); + if (gurl.is_valid() && gurl.IsStandard()) + is_file = false; FilePath full_path; - if (!ValidPathForFile(trimmed, &full_path)) { + if (is_file && !ValidPathForFile(trimmed, &full_path)) { // Not a path as entered, try unescaping it in case the user has // escaped things. We need to go through 8-bit since the escaped values // only represent 8-bit values. diff --git a/chrome/browser/net/url_fixer_upper_unittest.cc b/chrome/browser/net/url_fixer_upper_unittest.cc index f49ea8f..abe248f 100644 --- a/chrome/browser/net/url_fixer_upper_unittest.cc +++ b/chrome/browser/net/url_fixer_upper_unittest.cc @@ -516,4 +516,11 @@ TEST(URLFixerUpperTest, FixupRelativeFile) { // done with the subdir EXPECT_TRUE(file_util::Delete(full_path, false)); EXPECT_TRUE(file_util::Delete(new_dir, true)); + + // Test that an obvious HTTP URL isn't accidentally treated as an absolute + // file path (on account of system-specific craziness). + FilePath empty_path; + FilePath http_url_path(FILE_PATH_LITERAL("http://../")); + EXPECT_TRUE(URLFixerUpper::FixupRelativeFile( + empty_path, http_url_path).SchemeIs("http")); } |