OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/filename_util.h" | 5 #include "net/base/filename_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 FileCase url_cases[] = { | 232 FileCase url_cases[] = { |
233 #if defined(OS_WIN) | 233 #if defined(OS_WIN) |
234 {L"C:\\foo\\bar.txt", "file:c|/foo\\bar.txt"}, | 234 {L"C:\\foo\\bar.txt", "file:c|/foo\\bar.txt"}, |
235 {L"C:\\foo\\bar.txt", "file:/c:/foo/bar.txt"}, | 235 {L"C:\\foo\\bar.txt", "file:/c:/foo/bar.txt"}, |
236 {L"\\\\foo\\bar.txt", "file://foo\\bar.txt"}, | 236 {L"\\\\foo\\bar.txt", "file://foo\\bar.txt"}, |
237 {L"C:\\foo\\bar.txt", "file:///c:/foo/bar.txt"}, | 237 {L"C:\\foo\\bar.txt", "file:///c:/foo/bar.txt"}, |
238 {L"\\\\foo\\bar.txt", "file:////foo\\bar.txt"}, | 238 {L"\\\\foo\\bar.txt", "file:////foo\\bar.txt"}, |
239 {L"\\\\foo\\bar.txt", "file:/foo/bar.txt"}, | 239 {L"\\\\foo\\bar.txt", "file:/foo/bar.txt"}, |
240 {L"\\\\foo\\bar.txt", "file://foo\\bar.txt"}, | 240 {L"\\\\foo\\bar.txt", "file://foo\\bar.txt"}, |
241 {L"C:\\foo\\bar.txt", "file:\\\\\\c:/foo/bar.txt"}, | 241 {L"C:\\foo\\bar.txt", "file:\\\\\\c:/foo/bar.txt"}, |
| 242 // %2f ('/') and %5c ('\\') are left alone by both GURL and |
| 243 // FileURLToFilePath. |
| 244 {L"C:\\foo%2f..%5cbar", "file:///C:\\foo%2f..%5cbar"}, |
242 #elif defined(OS_POSIX) | 245 #elif defined(OS_POSIX) |
243 {L"/c:/foo/bar.txt", "file:/c:/foo/bar.txt"}, | 246 {L"/c:/foo/bar.txt", "file:/c:/foo/bar.txt"}, |
244 {L"/c:/foo/bar.txt", "file:///c:/foo/bar.txt"}, | 247 {L"/c:/foo/bar.txt", "file:///c:/foo/bar.txt"}, |
245 {L"/foo/bar.txt", "file:/foo/bar.txt"}, | 248 {L"/foo/bar.txt", "file:/foo/bar.txt"}, |
246 {L"/c:/foo/bar.txt", "file:\\\\\\c:/foo/bar.txt"}, | 249 {L"/c:/foo/bar.txt", "file:\\\\\\c:/foo/bar.txt"}, |
247 {L"/foo/bar.txt", "file:foo/bar.txt"}, | 250 {L"/foo/bar.txt", "file:foo/bar.txt"}, |
248 {L"/bar.txt", "file://foo/bar.txt"}, | 251 {L"/bar.txt", "file://foo/bar.txt"}, |
249 {L"/foo/bar.txt", "file:///foo/bar.txt"}, | 252 {L"/foo/bar.txt", "file:///foo/bar.txt"}, |
250 {L"/foo/bar.txt", "file:////foo/bar.txt"}, | 253 {L"/foo/bar.txt", "file:////foo/bar.txt"}, |
251 {L"/foo/bar.txt", "file:////foo//bar.txt"}, | 254 {L"/foo/bar.txt", "file:////foo//bar.txt"}, |
252 {L"/foo/bar.txt", "file:////foo///bar.txt"}, | 255 {L"/foo/bar.txt", "file:////foo///bar.txt"}, |
253 {L"/foo/bar.txt", "file:////foo////bar.txt"}, | 256 {L"/foo/bar.txt", "file:////foo////bar.txt"}, |
254 {L"/c:/foo/bar.txt", "file:\\\\\\c:/foo/bar.txt"}, | 257 {L"/c:/foo/bar.txt", "file:\\\\\\c:/foo/bar.txt"}, |
255 {L"/c:/foo/bar.txt", "file:c:/foo/bar.txt"}, | 258 {L"/c:/foo/bar.txt", "file:c:/foo/bar.txt"}, |
| 259 // %2f ('/') and %5c ('\\') are left alone by both GURL and |
| 260 // FileURLToFilePath. |
| 261 {L"/foo%2f..%5cbar", "file:///foo%2f..%5cbar"}, |
256 // We get these wrong because GURL turns back slashes into forward | 262 // We get these wrong because GURL turns back slashes into forward |
257 // slashes. | 263 // slashes. |
258 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, | 264 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, |
259 // {L"/c|/foo%5Cbar.txt", "file:c|/foo\\bar.txt"}, | 265 // {L"/c|/foo%5Cbar.txt", "file:c|/foo\\bar.txt"}, |
260 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, | 266 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, |
261 // {L"/foo%5Cbar.txt", "file:////foo\\bar.txt"}, | 267 // {L"/foo%5Cbar.txt", "file:////foo\\bar.txt"}, |
262 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, | 268 // {L"/foo%5Cbar.txt", "file://foo\\bar.txt"}, |
263 #endif | 269 #endif |
264 }; | 270 }; |
265 for (size_t i = 0; i < arraysize(url_cases); i++) { | 271 for (size_t i = 0; i < arraysize(url_cases); i++) { |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 1073 } |
1068 | 1074 |
1069 for (size_t i = 0; i < arraysize(kUnsafePortableBasenamesForWindows); ++i) { | 1075 for (size_t i = 0; i < arraysize(kUnsafePortableBasenamesForWindows); ++i) { |
1070 EXPECT_TRUE(IsReservedNameOnWindows( | 1076 EXPECT_TRUE(IsReservedNameOnWindows( |
1071 base::FilePath(kUnsafePortableBasenamesForWindows[i]).value())) | 1077 base::FilePath(kUnsafePortableBasenamesForWindows[i]).value())) |
1072 << kUnsafePortableBasenamesForWindows[i]; | 1078 << kUnsafePortableBasenamesForWindows[i]; |
1073 } | 1079 } |
1074 } | 1080 } |
1075 | 1081 |
1076 } // namespace net | 1082 } // namespace net |
OLD | NEW |