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

Unified Diff: chrome/browser/download/download_manager_unittest.cc

Issue 83002: download filename fix (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager_unittest.cc
===================================================================
--- chrome/browser/download/download_manager_unittest.cc (revision 15065)
+++ chrome/browser/download/download_manager_unittest.cc (working copy)
@@ -18,11 +18,13 @@
void GetGeneratedFilename(const std::string& content_disposition,
const std::string& url,
const std::string& mime_type,
+ const std::string& referrer_charset,
std::wstring* generated_name_string) {
DownloadCreateInfo info;
info.content_disposition = content_disposition;
info.url = GURL(url);
info.mime_type = mime_type;
+ info.referrer_charset = referrer_charset;
FilePath generated_name;
download_manager_->GenerateFilename(&info, &generated_name);
*generated_name_string = generated_name.ToWStringHack();
@@ -335,7 +337,6 @@
"application/x-tar",
L"bar.bogus.tar"},
- // TODO(darin): Add some raw 8-bit Content-Disposition tests.
};
} // namespace
@@ -343,14 +344,35 @@
// Tests to ensure that the file names we generate from hints from the server
// (content-disposition, URL name, etc) don't cause security holes.
TEST_F(DownloadManagerTest, TestDownloadFilename) {
+ std::wstring file_name;
for (int i = 0; i < arraysize(kGeneratedFiles); ++i) {
- std::wstring file_name;
GetGeneratedFilename(kGeneratedFiles[i].disposition,
kGeneratedFiles[i].url,
kGeneratedFiles[i].mime_type,
+ "",
&file_name);
EXPECT_EQ(kGeneratedFiles[i].expected_name, file_name);
+ GetGeneratedFilename(kGeneratedFiles[i].disposition,
+ kGeneratedFiles[i].url,
+ kGeneratedFiles[i].mime_type,
+ "GBK",
+ &file_name);
+ EXPECT_EQ(kGeneratedFiles[i].expected_name, file_name);
}
+
+ // A couple of cases with raw 8bit characters in C-D.
+ GetGeneratedFilename("attachment; filename=caf\xc3\xa9.png",
+ "http://www.example.com/images?id=3",
+ "image/png",
+ "iso-8859-1",
+ &file_name);
+ EXPECT_EQ(L"caf\u00e9.png", file_name);
+ GetGeneratedFilename("attachment; filename=caf\xe5.png",
+ "http://www.example.com/images?id=3",
+ "image/png",
+ "windows-1253",
+ &file_name);
+ EXPECT_EQ(L"caf\u03b5.png", file_name);
}
namespace {
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698