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

Unified Diff: net/base/filename_util_unittest.cc

Issue 1704163003: FileURLToFilePath: Don't unescape '/' and '\\'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 4 years, 10 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 | « net/base/filename_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/filename_util_unittest.cc
diff --git a/net/base/filename_util_unittest.cc b/net/base/filename_util_unittest.cc
index 5e3fb7e1c9f91fe59b5702ce274034d87c6ce5aa..b332ac1fb654cff281fb547a0192f952fe3e8720 100644
--- a/net/base/filename_util_unittest.cc
+++ b/net/base/filename_util_unittest.cc
@@ -239,6 +239,9 @@ TEST(FilenameUtilTest, FileURLConversion) {
{L"\\\\foo\\bar.txt", "file:/foo/bar.txt"},
{L"\\\\foo\\bar.txt", "file://foo\\bar.txt"},
{L"C:\\foo\\bar.txt", "file:\\\\\\c:/foo/bar.txt"},
+ // %2f ('/') and %5c ('\\') are left alone by both GURL and
+ // FileURLToFilePath.
+ {L"C:\\foo%2f..%5cbar", "file:///C:\\foo%2f..%5cbar"},
#elif defined(OS_POSIX)
{L"/c:/foo/bar.txt", "file:/c:/foo/bar.txt"},
{L"/c:/foo/bar.txt", "file:///c:/foo/bar.txt"},
@@ -253,6 +256,9 @@ TEST(FilenameUtilTest, FileURLConversion) {
{L"/foo/bar.txt", "file:////foo////bar.txt"},
{L"/c:/foo/bar.txt", "file:\\\\\\c:/foo/bar.txt"},
{L"/c:/foo/bar.txt", "file:c:/foo/bar.txt"},
+ // %2f ('/') and %5c ('\\') are left alone by both GURL and
+ // FileURLToFilePath.
+ {L"/foo%2f..%5cbar", "file:///foo%2f..%5cbar"},
// We get these wrong because GURL turns back slashes into forward
// slashes.
// {L"/foo%5Cbar.txt", "file://foo\\bar.txt"},
@@ -785,6 +791,16 @@ TEST(FilenameUtilTest, GenerateFileName) {
"image/jpeg",
L"download",
L"download" JPEG_EXT},
+ {// Escaped slash, backslash, and leading periods in file name. The periods
+ // should be removed, both slashes replaced with dashes.
+ __LINE__,
+ "http://www.google.com/..%2f%5atest.html",
+ "",
+ "",
+ "",
+ "",
+ L"",
+ L"--test.html"},
mmenke 2016/02/17 22:59:59 This isn't exactly related to the fix. There's an
};
// Tests filename generation. Once the correct filename is
« no previous file with comments | « net/base/filename_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698