diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 22:50:30 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 22:50:30 +0000 |
commit | 39abe05d3ebc8e41704fca8af77ba0755dc40153 (patch) | |
tree | b1564a6c4ff108b4c89393340a3049164d3bde48 /net/base | |
parent | 5478c37c9b98c45a3a6f84ede2513938f9f25168 (diff) | |
download | chromium_src-39abe05d3ebc8e41704fca8af77ba0755dc40153.zip chromium_src-39abe05d3ebc8e41704fca8af77ba0755dc40153.tar.gz chromium_src-39abe05d3ebc8e41704fca8af77ba0755dc40153.tar.bz2 |
Change backslashes in download file path to underscores.
BUG=70702
TEST=Upload a file with apostrophes to mediafire.com, then download it.
Review URL: http://codereview.chromium.org/6286125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/net_util.cc | 9 | ||||
-rw-r--r-- | net/base/net_util_unittest.cc | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index b4082ec..0528d50 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1398,11 +1398,10 @@ string16 GetSuggestedFilename(const GURL& url, referrer_charset); if (!filename.empty()) { - // Remove any path information the server may have sent, take the name - // only. - std::string::size_type slashpos = filename.find_last_of("/\\"); - if (slashpos != std::string::npos) - filename = filename.substr(slashpos + 1); + // Replace any path information the server may have sent, by changing + // path separators with underscores. + ReplaceSubstringsAfterOffset(&filename, 0, "/", "_"); + ReplaceSubstringsAfterOffset(&filename, 0, "\\", "_"); // Next, remove "." from the beginning and end of the file name to avoid // tricks with hidden files, "..", and "." diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index bf51f1c..ebb3574 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -1098,7 +1098,12 @@ TEST(NetUtilTest, GetSuggestedFilename) { "Content-disposition: attachment; filename=\"../test.html\"", "", L"", - L"test.html"}, + L"_test.html"}, + {"http://www.google.com/", + "Content-disposition: attachment; filename=\"..\\test.html\"", + "", + L"", + L"_test.html"}, {"http://www.google.com/", "Content-disposition: attachment; filename=\"..\"", "", |