diff options
author | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 04:12:31 +0000 |
---|---|---|
committer | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 04:12:31 +0000 |
commit | 4915ec608f743890a74438f68571fed4dd2d54c2 (patch) | |
tree | 760be40ea871b53d1e9821648a288874e2c96e25 /net | |
parent | 3d5173ecb8d32eb3fec477122044d5e2322ae489 (diff) | |
download | chromium_src-4915ec608f743890a74438f68571fed4dd2d54c2.zip chromium_src-4915ec608f743890a74438f68571fed4dd2d54c2.tar.gz chromium_src-4915ec608f743890a74438f68571fed4dd2d54c2.tar.bz2 |
Normalize download file name on chromeos
ChromeOS file manager cannot handle non NFC encoded utf8 file names (because of
file path normalization done in webkit layer), so let's ensure we normalize
downloaded file names.
BUG=chromium-os:26028
TEST=downloaded file with nfd encoded names and made sure they can be handled by file manager
Review URL: https://chromiumcodereview.appspot.com/9854011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129128 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/net_util.cc | 9 | ||||
-rw-r--r-- | net/base/net_util_unittest.cc | 13 |
2 files changed, 21 insertions, 1 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 2ba3b46..21fb07f 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1505,6 +1505,15 @@ FilePath GenerateFileName(const GURL& url, #else FilePath generated_name(base::SysWideToNativeMB(UTF16ToWide(file_name))); #endif + +#if defined(OS_CHROMEOS) + // When doing file manager operations on ChromeOS, the file paths get + // normalized in WebKit layer, so let's ensure downloaded files have + // normalized names. Otherwise, we won't be able to handle files with NFD + // utf8 encoded characters in name. + file_util::NormalizeFileNameEncoding(&generated_name); +#endif + DCHECK(!generated_name.empty()); return generated_name; diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index 0577989..98d79a7 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -2080,7 +2080,18 @@ TEST(NetUtilTest, GenerateFileName) { "image/jpeg", L"download", L"image" JPEG_EXT - } + }, +#if defined(OS_CHROMEOS) + { // http://crosbug.com/26028 + "http://www.example.com/fooa%cc%88.txt", + "", + "", + "", + "image/jpeg", + L"foo\xe4", + L"foo\xe4.txt" + }, +#endif }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(selection_tests); ++i) |