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

Side by Side Diff: net/base/net_util_unittest.cc

Issue 7300005: Move filename determination to net_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 size_t input_offset; 375 size_t input_offset;
376 size_t output_offset; 376 size_t output_offset;
377 }; 377 };
378 378
379 struct CompliantHostCase { 379 struct CompliantHostCase {
380 const char* host; 380 const char* host;
381 const char* desired_tld; 381 const char* desired_tld;
382 bool expected_output; 382 bool expected_output;
383 }; 383 };
384 384
385 struct SuggestedFilenameCase { 385 struct GenerateFilenameCase {
386 const char* url; 386 const char* url;
387 const char* content_disp_header; 387 const char* content_disp_header;
388 const char* referrer_charset; 388 const char* referrer_charset;
389 const char* suggested_filename; 389 const char* suggested_filename;
390 const char* mime_type;
390 const wchar_t* default_filename; 391 const wchar_t* default_filename;
391 const wchar_t* expected_filename; 392 const wchar_t* expected_filename;
392 }; 393 };
393 394
394 struct UrlTestData { 395 struct UrlTestData {
395 const char* description; 396 const char* description;
396 const char* input; 397 const char* input;
397 const char* languages; 398 const char* languages;
398 FormatUrlTypes format_types; 399 FormatUrlTypes format_types;
399 UnescapeRule::Type escape_rules; 400 UnescapeRule::Type escape_rules;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 std::string DumpIPNumber(const IPAddressNumber& v) { 501 std::string DumpIPNumber(const IPAddressNumber& v) {
501 std::string out; 502 std::string out;
502 for (size_t i = 0; i < v.size(); ++i) { 503 for (size_t i = 0; i < v.size(); ++i) {
503 if (i != 0) 504 if (i != 0)
504 out.append(","); 505 out.append(",");
505 out.append(base::IntToString(static_cast<int>(v[i]))); 506 out.append(base::IntToString(static_cast<int>(v[i])));
506 } 507 }
507 return out; 508 return out;
508 } 509 }
509 510
511 void RunGenerateFileNameTestCase(const GenerateFilenameCase* test_case,
512 size_t iteration,
513 const char* suite) {
514 #if defined(OS_WIN)
515 string16 default_filename(test_case->default_filename);
516 #else
517 string16 default_filename(WideToUTF16(test_case->default_filename));
518 #endif
519 FilePath file_path = GenerateFileName(
520 GURL(test_case->url), test_case->content_disp_header,
521 test_case->referrer_charset, test_case->suggested_filename,
522 test_case->mime_type, default_filename);
523 EXPECT_EQ(test_case->expected_filename,
524 file_util::FilePathAsWString(file_path))
525 << "Iteration " << iteration << " of " << suite << ": " << test_case->url;
526 }
527
510 } // anonymous namespace 528 } // anonymous namespace
511 529
512 TEST(NetUtilTest, FileURLConversion) { 530 TEST(NetUtilTest, FileURLConversion) {
513 // a list of test file names and the corresponding URLs 531 // a list of test file names and the corresponding URLs
514 const FileCase round_trip_cases[] = { 532 const FileCase round_trip_cases[] = {
515 #if defined(OS_WIN) 533 #if defined(OS_WIN)
516 {L"C:\\foo\\bar.txt", "file:///C:/foo/bar.txt"}, 534 {L"C:\\foo\\bar.txt", "file:///C:/foo/bar.txt"},
517 {L"\\\\some computer\\foo\\bar.txt", 535 {L"\\\\some computer\\foo\\bar.txt",
518 "file://some%20computer/foo/bar.txt"}, // UNC 536 "file://some%20computer/foo/bar.txt"}, // UNC
519 {L"D:\\Name;with%some symbols*#", 537 {L"D:\\Name;with%some symbols*#",
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1058 }
1041 } 1059 }
1042 1060
1043 TEST(NetUtilTest, StripWWW) { 1061 TEST(NetUtilTest, StripWWW) {
1044 EXPECT_EQ(string16(), StripWWW(string16())); 1062 EXPECT_EQ(string16(), StripWWW(string16()));
1045 EXPECT_EQ(string16(), StripWWW(ASCIIToUTF16("www."))); 1063 EXPECT_EQ(string16(), StripWWW(ASCIIToUTF16("www.")));
1046 EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("www.blah"))); 1064 EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("www.blah")));
1047 EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("blah"))); 1065 EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("blah")));
1048 } 1066 }
1049 1067
1050 TEST(NetUtilTest, GetSuggestedFilename) { 1068 #if defined(OS_WIN)
1051 const SuggestedFilenameCase test_cases[] = { 1069 #define JPEG_EXT L".jpg"
1070 #define HTML_EXT L".htm"
1071 #define TXT_EXT L".txt"
1072 #define TAR_EXT L".tar"
1073 #elif defined(OS_MACOSX)
1074 #define JPEG_EXT L".jpeg"
1075 #define HTML_EXT L".html"
1076 #define TXT_EXT L".txt"
1077 #define TAR_EXT L".tar"
1078 #else
1079 #define JPEG_EXT L".jpg"
1080 #define HTML_EXT L".html"
1081 #define TXT_EXT L".txt"
1082 #define TAR_EXT L".tar"
1083 #endif
1084
1085 TEST(NetUtilTest, GenerateSafeFileName) {
1086 const struct {
1087 const char* mime_type;
1088 const FilePath::CharType* filename;
1089 const FilePath::CharType* expected_filename;
1090 } safe_tests[] = {
1091 #if defined(OS_WIN)
1092 {"text/html",
1093 FILE_PATH_LITERAL("C:\\foo\\bar.htm"),
1094 FILE_PATH_LITERAL("C:\\foo\\bar.htm")},
rvargas (doing something else) 2011/07/26 00:10:57 nit: now that we're here let's get closer to the r
asanka 2011/07/28 20:04:38 Done.
1095
1096 {"text/html",
1097 FILE_PATH_LITERAL("C:\\foo\\bar.html"),
1098 FILE_PATH_LITERAL("C:\\foo\\bar.html")},
1099
1100 {"text/html",
1101 FILE_PATH_LITERAL("C:\\foo\\bar"),
1102 FILE_PATH_LITERAL("C:\\foo\\bar.htm")},
1103
1104 {"image/png",
1105 FILE_PATH_LITERAL("C:\\bar.html"),
1106 FILE_PATH_LITERAL("C:\\bar.html")},
1107
1108 {"image/png",
1109 FILE_PATH_LITERAL("C:\\bar"),
1110 FILE_PATH_LITERAL("C:\\bar.png")},
1111
1112 {"text/html",
1113 FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
1114 FILE_PATH_LITERAL("C:\\foo\\bar.exe")},
1115
1116 {"image/gif",
1117 FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
1118 FILE_PATH_LITERAL("C:\\foo\\bar.exe")},
1119
1120 {"text/html",
1121 FILE_PATH_LITERAL("C:\\foo\\google.com"),
1122 FILE_PATH_LITERAL("C:\\foo\\google.com")},
1123
1124 {"text/html",
1125 FILE_PATH_LITERAL("C:\\foo\\con.htm"),
1126 FILE_PATH_LITERAL("C:\\foo\\_con.htm")},
1127
1128 {"text/html",
1129 FILE_PATH_LITERAL("C:\\foo\\con"),
1130 FILE_PATH_LITERAL("C:\\foo\\_con.htm")},
1131
1132 {"text/html",
1133 FILE_PATH_LITERAL("C:\\foo\\harmless.{not-really-this-may-be-a-guid}"),
rvargas (doing something else) 2011/07/26 00:10:57 This looks like a new test.
asanka 2011/07/28 20:04:38 Yup. I added a couple of new tests for validation
1134 FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
1135
1136 {"text/html",
1137 FILE_PATH_LITERAL("C:\\foo\\harmless.local"),
1138 FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
1139
1140 {"text/html",
1141 FILE_PATH_LITERAL("C:\\foo\\harmless.lnk"),
1142 FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
1143
1144 {"text/html",
1145 FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-"),
1146 FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-")},
1147 #else // !defined(OS_WIN)
1148 {"text/html",
1149 FILE_PATH_LITERAL("/foo/bar.htm"),
1150 FILE_PATH_LITERAL("/foo/bar.htm")},
1151
1152 {"text/html",
1153 FILE_PATH_LITERAL("/foo/bar.html"),
1154 FILE_PATH_LITERAL("/foo/bar.html")},
1155
1156 {"text/html",
1157 FILE_PATH_LITERAL("/foo/bar"),
1158 FILE_PATH_LITERAL("/foo/bar.html")},
1159
1160 {"image/png",
1161 FILE_PATH_LITERAL("/bar.html"),
1162 FILE_PATH_LITERAL("/bar.html")},
1163
1164 {"image/png",
1165 FILE_PATH_LITERAL("/bar"),
1166 FILE_PATH_LITERAL("/bar.png")},
1167
1168 {"image/gif",
1169 FILE_PATH_LITERAL("/foo/bar.exe"),
1170 FILE_PATH_LITERAL("/foo/bar.exe")},
1171
1172 {"text/html",
1173 FILE_PATH_LITERAL("/foo/google.com"),
1174 FILE_PATH_LITERAL("/foo/google.com")},
1175
1176 {"text/html",
1177 FILE_PATH_LITERAL("/foo/con.htm"),
1178 FILE_PATH_LITERAL("/foo/con.htm")},
1179
1180 {"text/html",
1181 FILE_PATH_LITERAL("/foo/con"),
1182 FILE_PATH_LITERAL("/foo/con.html")},
1183 #endif // !defined(OS_WIN)
1184 };
1185
1186 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(safe_tests); ++i) {
1187 FilePath file_path(safe_tests[i].filename);
1188 GenerateSafeFileName(safe_tests[i].mime_type, &file_path);
1189 EXPECT_EQ(safe_tests[i].expected_filename, file_path.value())
1190 << "Iteration " << i;
1191 }
1192 }
1193
1194 TEST(NetUtilTest, GenerateFileName) {
1195 #if defined(OS_POSIX) && !defined(OS_MACOSX)
1196 // This test doesn't run when the locale is not UTF-8 because some of the
1197 // string conversions fail. This is OK (we have the default value) but they
1198 // don't match our expectations.
1199 std::string locale = setlocale(LC_CTYPE, NULL);
1200 StringToLowerASCII(&locale);
1201 EXPECT_NE(std::string::npos, locale.find("utf-8"))
1202 << "Your locale (" << locale << ") must be set to UTF-8 "
1203 << "for this test to pass!";
1204 #endif
1205
1206 // Tests whether the correct filename is selected from the the given
1207 // parameters and that Content-Disposition headers are properly
1208 // handled including failovers when the header is malformed.
1209 const GenerateFilenameCase selection_tests[] = {
1052 {"http://www.google.com/", 1210 {"http://www.google.com/",
1053 "Content-disposition: attachment; filename=test.html", 1211 "Content-disposition: attachment; filename=test.html",
1054 "", 1212 "",
1055 "", 1213 "",
1056 L"", 1214 "",
1057 L"test.html"}, 1215 L"",
1216 L"test.html"},
1217
1058 {"http://www.google.com/", 1218 {"http://www.google.com/",
1059 "Content-disposition: attachment; filename=\"test.html\"", 1219 "Content-disposition: attachment; filename=\"test.html\"",
1060 "", 1220 "",
1061 "", 1221 "",
1062 L"", 1222 "",
1063 L"test.html"}, 1223 L"",
1224 L"test.html"},
1225
1064 {"http://www.google.com/", 1226 {"http://www.google.com/",
1065 "Content-disposition: attachment; filename= \"test.html\"", 1227 "Content-disposition: attachment; filename= \"test.html\"",
1066 "", 1228 "",
1067 "", 1229 "",
1068 L"", 1230 "",
1069 L"test.html"}, 1231 L"",
1232 L"test.html"},
1233
1070 {"http://www.google.com/", 1234 {"http://www.google.com/",
1071 "Content-disposition: attachment; filename = \"test.html\"", 1235 "Content-disposition: attachment; filename = \"test.html\"",
1072 "", 1236 "",
1073 "", 1237 "",
1074 L"", 1238 "",
1075 L"test.html"}, 1239 L"",
1240 L"test.html"},
1241
1242 // filename is whitespace. Should failover to URL host
1076 {"http://www.google.com/", 1243 {"http://www.google.com/",
1077 "Content-disposition: attachment; filename= ", 1244 "Content-disposition: attachment; filename= ",
1078 "", 1245 "",
1079 "", 1246 "",
1247 "",
1080 L"", 1248 L"",
1081 L"www.google.com"}, 1249 L"www.google.com"},
1250
1251 // No filename.
1082 {"http://www.google.com/path/test.html", 1252 {"http://www.google.com/path/test.html",
1083 "Content-disposition: attachment", 1253 "Content-disposition: attachment",
1084 "", 1254 "",
1085 "", 1255 "",
1086 L"", 1256 "",
1087 L"test.html"}, 1257 L"",
1258 L"test.html"},
1259
1260 // Ditto
1088 {"http://www.google.com/path/test.html", 1261 {"http://www.google.com/path/test.html",
1089 "Content-disposition: attachment;", 1262 "Content-disposition: attachment;",
1090 "", 1263 "",
1091 "", 1264 "",
1092 L"", 1265 "",
1093 L"test.html"}, 1266 L"",
1094 {"http://www.google.com/", 1267 L"test.html"},
1268
1269 // No C-D
1270 {"http://www.google.com/",
1271 "",
1095 "", 1272 "",
1096 "", 1273 "",
1097 "", 1274 "",
1098 L"", 1275 L"",
1099 L"www.google.com"}, 1276 L"www.google.com"},
1277
1100 {"http://www.google.com/test.html", 1278 {"http://www.google.com/test.html",
1101 "", 1279 "",
1102 "", 1280 "",
1103 "", 1281 "",
1104 L"", 1282 "",
1105 L"test.html"}, 1283 L"",
1284 L"test.html"},
1285
1106 // Now that we use googleurl's ExtractFileName, this case falls back 1286 // Now that we use googleurl's ExtractFileName, this case falls back
1107 // to the hostname. If this behavior is not desirable, we'd better 1287 // to the hostname. If this behavior is not desirable, we'd better
1108 // change ExtractFileName (in url_parse). 1288 // change ExtractFileName (in url_parse).
1109 {"http://www.google.com/path/", 1289 {"http://www.google.com/path/",
1110 "", 1290 "",
1111 "", 1291 "",
1112 "", 1292 "",
1293 "",
1113 L"", 1294 L"",
1114 L"www.google.com"}, 1295 L"www.google.com"},
1296
1115 {"http://www.google.com/path", 1297 {"http://www.google.com/path",
1116 "", 1298 "",
1117 "", 1299 "",
1118 "", 1300 "",
1301 "",
1119 L"", 1302 L"",
1120 L"path"}, 1303 L"path"},
1304
1121 {"file:///", 1305 {"file:///",
1122 "", 1306 "",
1123 "", 1307 "",
1124 "", 1308 "",
1125 L"", 1309 "",
1126 L"download"}, 1310 L"",
1311 L"download"},
1312
1313 {"file:///path/testfile",
1314 "",
1315 "",
1316 "",
1317 "",
1318 L"",
1319 L"testfile"},
1320
1127 {"non-standard-scheme:", 1321 {"non-standard-scheme:",
1128 "", 1322 "",
1129 "", 1323 "",
1130 "", 1324 "",
1131 L"", 1325 "",
1132 L"download"}, 1326 L"",
1327 L"download"},
1328
1329 // C-D should override default
1133 {"http://www.google.com/", 1330 {"http://www.google.com/",
1134 "Content-disposition: attachment; filename =\"test.html\"", 1331 "Content-disposition: attachment; filename =\"test.html\"",
1135 "", 1332 "",
1136 "", 1333 "",
1137 L"download", 1334 "",
1138 L"test.html"}, 1335 L"download",
1139 {"http://www.google.com/", 1336 L"test.html"},
1140 "", 1337
1141 "", 1338 // But the URL shouldn't
1142 "", 1339 {"http://www.google.com/",
1143 L"download", 1340 "",
1144 L"download"}, 1341 "",
1342 "",
1343 "",
1344 L"download",
1345 L"download"},
1346
1145 {"http://www.google.com/", 1347 {"http://www.google.com/",
1146 "Content-disposition: attachment; filename=\"../test.html\"", 1348 "Content-disposition: attachment; filename=\"../test.html\"",
1147 "", 1349 "",
1148 "", 1350 "",
1351 "",
1149 L"", 1352 L"",
1150 L"_test.html"}, 1353 L"_test.html"},
1354
1151 {"http://www.google.com/", 1355 {"http://www.google.com/",
1152 "Content-disposition: attachment; filename=\"..\\test.html\"", 1356 "Content-disposition: attachment; filename=\"..\\test.html\"",
1153 "", 1357 "",
1154 "", 1358 "",
1359 "",
1155 L"", 1360 L"",
1156 L"_test.html"}, 1361 L"_test.html"},
1362
1363 // Filename disappears after leading and trailing periods are
1364 // removed.
1157 {"http://www.google.com/", 1365 {"http://www.google.com/",
1158 "Content-disposition: attachment; filename=\"..\"", 1366 "Content-disposition: attachment; filename=\"..\"",
1159 "", 1367 "",
1160 "", 1368 "",
1161 L"download", 1369 "",
1162 L"download"}, 1370 L"default",
1371 L"default"},
1372
1373 // Failover to last component of URL
1163 {"http://www.google.com/test.html", 1374 {"http://www.google.com/test.html",
1164 "Content-disposition: attachment; filename=\"..\"", 1375 "Content-disposition: attachment; filename=\"..\"",
1165 "", 1376 "",
1166 "", 1377 "",
1167 L"download", 1378 "",
1168 L"test.html"}, 1379 L"download",
1380 L"test.html"},
1381
1169 // Below is a small subset of cases taken from GetFileNameFromCD test above. 1382 // Below is a small subset of cases taken from GetFileNameFromCD test above.
1170 {"http://www.google.com/", 1383 {"http://www.google.com/",
1171 "Content-Disposition: attachment; filename=\"%EC%98%88%EC%88%A0%20" 1384 "Content-Disposition: attachment; filename=\"%EC%98%88%EC%88%A0%20"
1172 "%EC%98%88%EC%88%A0.jpg\"", 1385 "%EC%98%88%EC%88%A0.jpg\"",
1173 "", 1386 "",
1174 "", 1387 "",
1175 L"", 1388 "",
1176 L"\uc608\uc220 \uc608\uc220.jpg"}, 1389 L"",
1390 L"\uc608\uc220 \uc608\uc220.jpg"
1391 },
1392
1177 {"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg", 1393 {"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
1178 "", 1394 "",
1179 "", 1395 "",
1180 "", 1396 "",
1181 L"download", 1397 "",
1182 L"\uc608\uc220 \uc608\uc220.jpg"}, 1398 L"download",
1399 L"\uc608\uc220 \uc608\uc220.jpg"
1400 },
1401
1183 {"http://www.google.com/", 1402 {"http://www.google.com/",
1184 "Content-disposition: attachment;", 1403 "Content-disposition: attachment;",
1185 "", 1404 "",
1186 "", 1405 "",
1406 "",
1187 L"\uB2E4\uC6B4\uB85C\uB4DC", 1407 L"\uB2E4\uC6B4\uB85C\uB4DC",
1188 L"\uB2E4\uC6B4\uB85C\uB4DC"}, 1408 L"\uB2E4\uC6B4\uB85C\uB4DC"
1409 },
1410
1189 {"http://www.google.com/", 1411 {"http://www.google.com/",
1190 "Content-Disposition: attachment; filename=\"=?EUC-JP?Q?=B7=DD=BD=" 1412 "Content-Disposition: attachment; filename=\"=?EUC-JP?Q?=B7=DD=BD="
1191 "D13=2Epng?=\"", 1413 "D13=2Epng?=\"",
1192 "", 1414 "",
1193 "", 1415 "",
1416 "",
1194 L"download", 1417 L"download",
1195 L"\u82b8\u88533.png"}, 1418 L"\u82b8\u88533.png"},
1419
1196 {"http://www.example.com/images?id=3", 1420 {"http://www.example.com/images?id=3",
1197 "Content-Disposition: attachment; filename=caf\xc3\xa9.png", 1421 "Content-Disposition: attachment; filename=caf\xc3\xa9.png",
1198 "iso-8859-1", 1422 "iso-8859-1",
1199 "", 1423 "",
1200 L"", 1424 "",
1201 L"caf\u00e9.png"}, 1425 L"",
1426 L"caf\u00e9.png"
1427 },
1428
1202 {"http://www.example.com/images?id=3", 1429 {"http://www.example.com/images?id=3",
1203 "Content-Disposition: attachment; filename=caf\xe5.png", 1430 "Content-Disposition: attachment; filename=caf\xe5.png",
1204 "windows-1253", 1431 "windows-1253",
1205 "", 1432 "",
1433 "",
1206 L"", 1434 L"",
1207 L"caf\u03b5.png"}, 1435 L"caf\u03b5.png"},
1436
1208 {"http://www.example.com/file?id=3", 1437 {"http://www.example.com/file?id=3",
1209 "Content-Disposition: attachment; name=\xcf\xc2\xd4\xd8.zip", 1438 "Content-Disposition: attachment; name=\xcf\xc2\xd4\xd8.zip",
1210 "GBK", 1439 "GBK",
1211 "", 1440 "",
1441 "",
1212 L"", 1442 L"",
1213 L"\u4e0b\u8f7d.zip"}, 1443 L"\u4e0b\u8f7d.zip"},
1444
1214 // Invalid C-D header. Extracts filename from url. 1445 // Invalid C-D header. Extracts filename from url.
1215 {"http://www.google.com/test.html", 1446 {"http://www.google.com/test.html",
1216 "Content-Disposition: attachment; filename==?iiso88591?Q?caf=EG?=", 1447 "Content-Disposition: attachment; filename==?iiso88591?Q?caf=EG?=",
1217 "", 1448 "",
1218 "", 1449 "",
1219 L"", 1450 "",
1220 L"test.html"}, 1451 L"",
1452 L"test.html"},
1453
1221 // about: and data: URLs 1454 // about: and data: URLs
1222 {"about:chrome", 1455 {"about:chrome",
1223 "", 1456 "",
1224 "", 1457 "",
1225 "", 1458 "",
1226 L"", 1459 "",
1227 L"download"}, 1460 L"",
1461 L"download"},
1462
1228 {"data:,looks/like/a.path", 1463 {"data:,looks/like/a.path",
1229 "", 1464 "",
1230 "", 1465 "",
1231 "", 1466 "",
1232 L"", 1467 "",
1233 L"download"}, 1468 L"",
1469 L"download"},
1470
1234 {"data:text/plain;base64,VG8gYmUgb3Igbm90IHRvIGJlLg=", 1471 {"data:text/plain;base64,VG8gYmUgb3Igbm90IHRvIGJlLg=",
1235 "", 1472 "",
1236 "", 1473 "",
1237 "", 1474 "",
1238 L"", 1475 "",
1239 L"download"}, 1476 L"",
1477 L"download"},
1478
1240 {"data:,looks/like/a.path", 1479 {"data:,looks/like/a.path",
1241 "", 1480 "",
1242 "", 1481 "",
1243 "", 1482 "",
1483 "",
1244 L"default_filename_is_given", 1484 L"default_filename_is_given",
1245 L"default_filename_is_given"}, 1485 L"default_filename_is_given"},
1486
1246 {"data:,looks/like/a.path", 1487 {"data:,looks/like/a.path",
1247 "", 1488 "",
1248 "", 1489 "",
1249 "", 1490 "",
1491 "",
1250 L"\u65e5\u672c\u8a9e", // Japanese Kanji. 1492 L"\u65e5\u672c\u8a9e", // Japanese Kanji.
1251 L"\u65e5\u672c\u8a9e"}, 1493 L"\u65e5\u672c\u8a9e"},
1252 // Dotfiles. Ensures preceeding period(s) stripped. 1494
1253 {"http://www.google.com/.test.html",
1254 "",
1255 "",
1256 "",
1257 L"",
1258 L"test.html"},
1259 {"http://www.google.com/.test",
1260 "",
1261 "",
1262 "",
1263 L"",
1264 L"test"},
1265 {"http://www.google.com/..test",
1266 "",
1267 "",
1268 "",
1269 L"",
1270 L"test"},
1271 // The filename encoding is specified by the referrer charset. 1495 // The filename encoding is specified by the referrer charset.
1272 {"http://example.com/V%FDvojov%E1%20psychologie.doc", 1496 {"http://example.com/V%FDvojov%E1%20psychologie.doc",
1273 "", 1497 "",
1274 "iso-8859-1", 1498 "iso-8859-1",
1275 "", 1499 "",
1276 L"", 1500 "",
1277 L"V\u00fdvojov\u00e1 psychologie.doc"}, 1501 L"",
1502 L"V\u00fdvojov\u00e1 psychologie.doc"
1503 },
1504
1505 // Suggested filename takes precedence over URL
1278 {"http://www.google.com/test", 1506 {"http://www.google.com/test",
1279 "", 1507 "",
1280 "", 1508 "",
1281 "suggested", 1509 "suggested",
1510 "",
1282 L"", 1511 L"",
1283 L"suggested"}, 1512 L"suggested"},
1513
1284 // The content-disposition has higher precedence over the suggested name. 1514 // The content-disposition has higher precedence over the suggested name.
1285 {"http://www.google.com/test", 1515 {"http://www.google.com/test",
1286 "Content-disposition: attachment; filename=test.html", 1516 "Content-disposition: attachment; filename=test.html",
1287 "", 1517 "",
1288 "suggested", 1518 "suggested",
1289 L"", 1519 "",
1290 L"test.html"}, 1520 L"",
1521 L"test.html"},
1522
1291 // The filename encoding doesn't match the referrer charset, the 1523 // The filename encoding doesn't match the referrer charset, the
1292 // system charset, or UTF-8. 1524 // system charset, or UTF-8.
1293 // TODO(jshin): we need to handle this case. 1525 // TODO(jshin): we need to handle this case.
1294 #if 0 1526 #if 0
1295 {"http://example.com/V%FDvojov%E1%20psychologie.doc", 1527 {"http://example.com/V%FDvojov%E1%20psychologie.doc",
1296 "", 1528 "",
1297 "utf-8", 1529 "utf-8",
1298 "", 1530 "",
1531 "",
1299 L"", 1532 L"",
1300 L"V\u00fdvojov\u00e1 psychologie.doc", 1533 L"V\u00fdvojov\u00e1 psychologie.doc",
1301 }, 1534 },
1302 #endif 1535 #endif
1536
1537 // Raw 8bit characters in C-D
1538 {"http://www.example.com/images?id=3",
1539 "Content-Disposition: attachment; filename=caf\xc3\xa9.png",
1540 "iso-8859-1",
1541 "",
1542 "image/png",
1543 L"",
1544 L"caf\u00e9.png"
1545 },
1546
1547 {"http://www.example.com/images?id=3",
1548 "Content-Disposition: attachment; filename=caf\xe5.png",
1549 "windows-1253",
1550 "",
1551 "image/png",
1552 L"",
1553 L"caf\u03b5.png"
1554 },
1555
1556 // No 'filename' keyword in the disposition, use the URL
1557 {"http://www.evil.com/my_download.txt",
1558 "Content-Dispostion: a_file_name.txt",
1559 "",
1560 "",
1561 "text/plain",
1562 L"download",
1563 L"my_download.txt"},
1564
1565 // Spaces in the disposition file name
1566 {"http://www.frontpagehacker.com/a_download.exe",
1567 "Content-Dispostion: filename=My Downloaded File.exe",
1568 "",
1569 "",
1570 "application/octet-stream",
1571 L"download",
1572 L"My Downloaded File.exe"},
1573
1574 // % encoded
1575 {"http://www.examples.com/",
1576 "Content-Dispostion: attachment; "
1577 "filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"",
1578 "",
1579 "",
1580 "image/jpeg",
1581 L"download",
1582 L"\uc608\uc220 \uc608\uc220.jpg"
1583 },
1584
1585 // name= parameter
1586 {"http://www.examples.com/q.cgi?id=abc",
1587 "Content-Dispostion: attachment; name=abc de.pdf",
1588 "",
1589 "",
1590 "application/octet-stream",
1591 L"download",
1592 L"abc de.pdf"},
1593
1594 {"http://www.example.com/path",
1595 "Content-Dispostion: filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"",
1596 "",
1597 "",
1598 "image/png",
1599 L"download",
1600 L"\x82b8\x8853" L"3.png"},
1601
1602 // The following two have invalid CD headers and filenames come
1603 // from the URL.
1604 {"http://www.example.com/test%20123",
1605 "Content-Dispostion: attachment; filename==?iiso88591?Q?caf=EG?=",
1606 "",
1607 "",
1608 "image/jpeg",
1609 L"download",
1610 L"test 123" JPEG_EXT
1611 },
1612
1613 {"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
1614 "Content-Dispostion: malformed_disposition",
1615 "",
1616 "",
1617 "image/jpeg",
1618 L"download",
1619 L"\uc608\uc220 \uc608\uc220.jpg"
1620 },
1621
1622 // Invalid C-D. No filename from URL. Falls back to 'download'.
1623 {"http://www.google.com/path1/path2/",
1624 "Content-Dispostion: attachment; filename==?iso88591?Q?caf=E3?",
1625 "",
1626 "",
1627 "image/jpeg",
1628 L"download",
1629 L"download" JPEG_EXT
1630 },
1303 }; 1631 };
1304 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 1632
1305 std::wstring default_name = test_cases[i].default_filename; 1633 // Tests filename generation. Once the correct filename is
1306 string16 filename = GetSuggestedFilename( 1634 // selected, they should be passed through the validation steps and
1307 GURL(test_cases[i].url), test_cases[i].content_disp_header, 1635 // a correct extension should be added if necessary.
1308 test_cases[i].referrer_charset, test_cases[i].suggested_filename, 1636 const GenerateFilenameCase generation_tests[] = {
1309 WideToUTF16(default_name)); 1637 // Dotfiles. Ensures preceeding period(s) stripped.
1310 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), 1638 {"http://www.google.com/.test.html",
1311 UTF16ToWide(filename)) 1639 "",
1312 << "Iteration " << i << ": " << test_cases[i].url; 1640 "",
1641 "",
1642 "",
1643 L"",
1644 L"test.html"},
1645
1646 {"http://www.google.com/.test",
1647 "",
1648 "",
1649 "",
1650 "",
1651 L"",
1652 L"test"},
1653
1654 {"http://www.google.com/..test",
1655 "",
1656 "",
1657 "",
1658 "",
1659 L"",
1660 L"test"},
1661
1662 // Disposition has relative paths, remove directory separators
1663 {"http://www.evil.com/my_download.txt",
1664 "Content-Dispostion: filename=../../../../././../a_file_name.txt",
1665 "",
1666 "",
1667 "text/plain",
1668 L"download",
1669 L"_.._.._.._._._.._a_file_name.txt"},
1670
1671 // Disposition has parent directories, remove directory separators
1672 {"http://www.evil.com/my_download.txt",
1673 "Content-Dispostion: filename=dir1/dir2/a_file_name.txt",
1674 "",
1675 "",
1676 "text/plain",
1677 L"download",
1678 L"dir1_dir2_a_file_name.txt"},
1679
1680 // Disposition has relative paths, remove directory separators
1681 {"http://www.evil.com/my_download.txt",
1682 "Content-Dispostion: filename=..\\..\\..\\..\\.\\.\\..\\a_file_name.txt",
1683 "",
1684 "",
1685 "text/plain",
1686 L"download",
1687 L"_.._.._.._._._.._a_file_name.txt"},
1688
1689 // Disposition has parent directories, remove directory separators
1690 {"http://www.evil.com/my_download.txt",
1691 "Content-Dispostion: filename=dir1\\dir2\\a_file_name.txt",
1692 "",
1693 "",
1694 "text/plain",
1695 L"download",
1696 L"dir1_dir2_a_file_name.txt"},
1697
1698 // No useful information in disposition or URL, use default
1699 {"http://www.truncated.com/path/",
1700 "",
1701 "",
1702 "",
1703 "text/plain",
1704 L"download",
1705 L"download" TXT_EXT
1706 },
1707
1708 // Filename looks like HTML?
1709 {"http://www.evil.com/get/malware/here",
1710 "Content-Disposition: filename=\"<blink>Hello kitty</blink>\"",
1711 "",
1712 "",
1713 "text/plain",
1714 L"default",
1715 L"-blink-Hello kitty-_blink-" TXT_EXT
1716 },
1717
1718 // A normal avi should get .avi and not .avi.avi
1719 {"https://blah.google.com/misc/2.avi",
1720 "",
1721 "",
1722 "",
1723 "video/x-msvideo",
1724 L"download",
1725 L"2.avi"},
1726
1727 // Extension generation
1728 {"http://www.example.com/my-cat",
1729 "Content-Disposition: filename=my-cat",
1730 "",
1731 "",
1732 "image/jpeg",
1733 L"download",
1734 L"my-cat" JPEG_EXT
1735 },
1736
1737 {"http://www.example.com/my-cat",
1738 "Content-Dispostion: filename=my-cat",
1739 "",
1740 "",
1741 "text/plain",
1742 L"download",
1743 L"my-cat.txt"},
1744
1745 {"http://www.example.com/my-cat",
1746 "Content-Dispostion: filename=my-cat",
1747 "",
1748 "",
1749 "text/html",
1750 L"download",
1751 L"my-cat" HTML_EXT
1752 },
1753
1754 // Unknown MIME type
1755 {"http://www.example.com/my-cat",
1756 "Content-Dispostion: filename=my-cat",
1757 "",
1758 "",
1759 "dance/party",
1760 L"download",
1761 L"my-cat"},
1762
1763 {"http://www.example.com/my-cat.jpg",
1764 "Content-Dispostion: filename=my-cat.jpg",
1765 "",
1766 "",
1767 "text/plain",
1768 L"download",
1769 L"my-cat.jpg"},
1770
1771 // Windows specific tests
1772 #if defined(OS_WIN)
1773 {"http://www.goodguy.com/evil.exe",
1774 "Content-Dispostion: filename=evil.exe",
1775 "",
1776 "",
1777 "image/jpeg",
1778 L"download",
1779 L"evil.exe"},
1780
1781 {"http://www.goodguy.com/ok.exe",
1782 "Content-Dispostion: filename=ok.exe",
1783 "",
1784 "",
1785 "binary/octet-stream",
1786 L"download",
1787 L"ok.exe"},
1788
1789 {"http://www.goodguy.com/evil.dll",
1790 "Content-Dispostion: filename=evil.dll",
1791 "",
1792 "",
1793 "dance/party",
1794 L"download",
1795 L"evil.dll"},
1796
1797 {"http://www.goodguy.com/evil.exe",
1798 "Content-Dispostion: filename=evil",
1799 "",
1800 "",
1801 "application/rss+xml",
1802 L"download",
1803 L"evil"},
1804
1805 // Test truncation of trailing dots and spaces
1806 {"http://www.goodguy.com/evil.exe ",
1807 "Content-Dispostion: filename=evil.exe ",
1808 "",
1809 "",
1810 "binary/octet-stream",
1811 L"download",
1812 L"evil.exe"},
1813
1814 {"http://www.goodguy.com/evil.exe.",
1815 "Content-Dispostion: filename=evil.exe.",
1816 "",
1817 "",
1818 "binary/octet-stream",
1819 L"download",
1820 L"evil.exe"},
1821
1822 {"http://www.goodguy.com/evil.exe. . .",
1823 "Content-Dispostion: filename=evil.exe. . .",
1824 "",
1825 "",
1826 "binary/octet-stream",
1827 L"download",
1828 L"evil.exe"},
1829
1830 {"http://www.goodguy.com/evil.",
1831 "Content-Dispostion: filename=evil.",
1832 "",
1833 "",
1834 "binary/octet-stream",
1835 L"download",
1836 L"evil"},
1837
1838 {"http://www.goodguy.com/. . . . .",
1839 "Content-Dispostion: filename=. . . . .",
1840 "",
1841 "",
1842 "binary/octet-stream",
1843 L"download",
1844 L"download"},
1845
1846 #endif // OS_WIN
1847
1848 {"http://www.goodguy.com/utils.js",
1849 "Content-Dispostion: filename=utils.js",
1850 "",
1851 "",
1852 "application/x-javascript",
1853 L"download",
1854 L"utils.js"},
1855
1856 {"http://www.goodguy.com/contacts.js",
1857 "Content-Dispostion: filename=contacts.js",
1858 "",
1859 "",
1860 "application/json",
1861 L"download",
1862 L"contacts.js"},
1863
1864 {"http://www.goodguy.com/utils.js",
1865 "Content-Dispostion: filename=utils.js",
1866 "",
1867 "",
1868 "text/javascript",
1869 L"download",
1870 L"utils.js"},
1871
1872 {"http://www.goodguy.com/utils.js",
1873 "Content-Dispostion: filename=utils.js",
1874 "",
1875 "",
1876 "text/javascript;version=2",
1877 L"download",
1878 L"utils.js"},
1879
1880 {"http://www.goodguy.com/utils.js",
1881 "Content-Dispostion: filename=utils.js",
1882 "",
1883 "",
1884 "application/ecmascript",
1885 L"download",
1886 L"utils.js"},
1887
1888 {"http://www.goodguy.com/utils.js",
1889 "Content-Dispostion: filename=utils.js",
1890 "",
1891 "",
1892 "application/ecmascript;version=4",
1893 L"download",
1894 L"utils.js"},
1895
1896 {"http://www.goodguy.com/program.exe",
1897 "Content-Dispostion: filename=program.exe",
1898 "",
1899 "",
1900 "application/foo-bar",
1901 L"download",
1902 L"program.exe"},
1903
1904 {"http://www.evil.com/../foo.txt",
1905 "Content-Dispostion: filename=../foo.txt",
1906 "",
1907 "",
1908 "text/plain",
1909 L"download",
1910 L"_foo.txt"},
1911
1912 {"http://www.evil.com/..\\foo.txt",
1913 "Content-Dispostion: filename=..\\foo.txt",
1914 "",
1915 "",
1916 "text/plain",
1917 L"download",
1918 L"_foo.txt"
1919 },
1920
1921 {"http://www.evil.com/.hidden",
1922 "Content-Dispostion: filename=.hidden",
1923 "",
1924 "",
1925 "text/plain",
1926 L"download",
1927 L"hidden" TXT_EXT
1928 },
1929
1930 {"http://www.evil.com/trailing.",
1931 "Content-Disposition: filename=trailing.",
1932 "",
1933 "",
1934 "dance/party",
1935 L"download",
1936 L"trailing"
1937 },
1938
1939 {"http://www.evil.com/trailing.",
1940 "Content-Disposition: filename=trailing.",
1941 "",
1942 "",
1943 "text/plain",
1944 L"download",
1945 L"trailing" TXT_EXT
1946 },
1947
1948 {"http://www.evil.com/.",
1949 "Content-Dispostion: filename=.",
1950 "",
1951 "",
1952 "dance/party",
1953 L"download",
1954 L"download"},
1955
1956 {"http://www.evil.com/..",
1957 "Content-Dispostion: filename=..",
1958 "",
1959 "",
1960 "dance/party",
1961 L"download",
1962 L"download"},
1963
1964 {"http://www.evil.com/...",
1965 "Content-Dispostion: filename=...",
1966 "",
1967 "",
1968 "dance/party",
1969 L"download",
1970 L"download"},
1971
1972 // Note that this one doesn't have "filename=" on it.
1973 {"http://www.evil.com/",
1974 "Content-Dispostion: a_file_name.txt",
1975 "",
1976 "",
1977 "image/jpeg",
1978 L"download",
1979 L"download" JPEG_EXT
1980 },
1981
1982 {"http://www.evil.com/",
1983 "Content-Dispostion: filename=",
1984 "",
1985 "",
1986 "image/jpeg",
1987 L"download",
1988 L"download" JPEG_EXT
1989 },
1990
1991 {"http://www.example.com/simple",
1992 "Content-Dispostion: filename=simple",
1993 "",
1994 "",
1995 "application/octet-stream",
1996 L"download",
1997 L"simple"},
1998
1999 // Reserved words on Windows
2000 {"http://www.goodguy.com/COM1",
2001 "Content-Dispostion: filename=COM1",
2002 "",
2003 "",
2004 "application/foo-bar",
2005 L"download",
2006 #if defined(OS_WIN)
2007 L"_COM1"
2008 #else
2009 L"COM1"
2010 #endif
2011 },
2012
2013 {"http://www.goodguy.com/COM4.txt",
2014 "Content-Dispostion: filename=COM4.txt",
2015 "",
2016 "",
2017 "text/plain",
2018 L"download",
2019 #if defined(OS_WIN)
2020 L"_COM4.txt"
2021 #else
2022 L"COM4.txt"
2023 #endif
2024 },
2025
2026 {"http://www.goodguy.com/lpt1.TXT",
2027 "Content-Dispostion: filename=lpt1.TXT",
2028 "",
2029 "",
2030 "text/plain",
2031 L"download",
2032 #if defined(OS_WIN)
2033 L"_lpt1.TXT"
2034 #else
2035 L"lpt1.TXT"
2036 #endif
2037 },
2038
2039 {"http://www.goodguy.com/clock$.txt",
2040 "Content-Dispostion: filename=clock$.txt",
2041 "",
2042 "",
2043 "text/plain",
2044 L"download",
2045 #if defined(OS_WIN)
2046 L"_clock$.txt"
2047 #else
2048 L"clock$.txt"
2049 #endif
2050 },
2051
2052 // Validation should also apply to sugested name
2053 {"http://www.goodguy.com/blah$.txt",
2054 "Content-Dispostion: filename=clock$.txt",
2055 "",
2056 "clock$.txt",
2057 "text/plain",
2058 L"download",
2059 #if defined(OS_WIN)
2060 L"_clock$.txt"
2061 #else
2062 L"clock$.txt"
2063 #endif
2064 },
2065
2066 {"http://www.goodguy.com/mycom1.foo",
2067 "Content-Dispostion: filename=mycom1.foo",
2068 "",
2069 "",
2070 "text/plain",
2071 L"download",
2072 L"mycom1.foo"},
2073
2074 {"http://www.badguy.com/Setup.exe.local",
2075 "Content-Dispostion: filename=Setup.exe.local",
2076 "",
2077 "",
2078 "application/foo-bar",
2079 L"download",
2080 #if defined(OS_WIN)
2081 L"Setup.exe.download"
2082 #else
2083 L"Setup.exe.local"
2084 #endif
2085 },
2086
2087 {"http://www.badguy.com/Setup.exe.local",
2088 "filename=Setup.exe.local.local",
2089 "",
2090 "",
2091 "application/foo-bar",
2092 L"download",
2093 #if defined(OS_WIN)
2094 L"Setup.exe.local.download"
2095 #else
2096 L"Setup.exe.local.local"
2097 #endif
2098 },
2099
2100 {"http://www.badguy.com/Setup.exe.lnk",
2101 "Content-Dispostion: filename=Setup.exe.lnk",
2102 "",
2103 "",
2104 "application/foo-bar",
2105 L"download",
2106 #if defined(OS_WIN)
2107 L"Setup.exe.download"
2108 #else
2109 L"Setup.exe.lnk"
2110 #endif
2111 },
2112
2113 {"http://www.badguy.com/Desktop.ini",
2114 "Content-Dispostion: filename=Desktop.ini",
2115 "",
2116 "",
2117 "application/foo-bar",
2118 L"download",
2119 #if defined(OS_WIN)
2120 L"_Desktop.ini"
2121 #else
2122 L"Desktop.ini"
2123 #endif
2124 },
2125
2126 {"http://www.badguy.com/Thumbs.db",
2127 "Content-Dispostion: filename=Thumbs.db",
2128 "",
2129 "",
2130 "application/foo-bar",
2131 L"download",
2132 #if defined(OS_WIN)
2133 L"_Thumbs.db"
2134 #else
2135 L"Thumbs.db"
2136 #endif
2137 },
2138
2139 {"http://www.hotmail.com",
2140 "Content-Dispostion: filename=source.jpg",
2141 "",
2142 "",
2143 "application/x-javascript",
2144 L"download",
2145 L"source.jpg"
2146 },
2147
2148 // http://crbug.com/5772.
2149 {"http://www.example.com/foo.tar.gz",
2150 "Content-Dispostion: ",
2151 "",
2152 "",
2153 "application/x-tar",
2154 L"download",
2155 L"foo.tar.gz"},
2156
2157 // http://crbug.com/52250.
2158 {"http://www.example.com/foo.tgz",
2159 "Content-Dispostion: ",
2160 "",
2161 "",
2162 "application/x-tar",
2163 L"download",
2164 L"foo.tgz"},
2165
2166 // http://crbug.com/7337.
2167 {"http://maged.lordaeron.org/blank.reg",
2168 "Content-Dispostion: ",
2169 "",
2170 "",
2171 "text/x-registry",
2172 L"download",
2173 L"blank.reg"},
2174
2175 {"http://www.example.com/bar.tar",
2176 "Content-Dispostion: ",
2177 "",
2178 "",
2179 "application/x-tar",
2180 L"download",
2181 L"bar.tar"},
2182
2183 {"http://www.example.com/bar.bogus",
2184 "",
2185 "",
2186 "",
2187 "application/x-tar",
2188 L"download",
2189 L"bar.bogus"
2190 },
2191
2192 // http://crbug.com/20337
2193 {"http://www.example.com/.download.txt",
2194 "Content-Dispostion: filename=.download.txt",
2195 "",
2196 "",
2197 "text/plain",
2198 L"download",
2199 L"download.txt"},
2200
2201 // http://crbug.com/56855.
2202 {"http://www.example.com/bar.sh",
2203 "",
2204 "",
2205 "",
2206 "application/x-sh",
2207 L"download",
2208 L"bar.sh"
2209 },
2210 };
2211
2212 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(selection_tests); ++i)
2213 RunGenerateFileNameTestCase(&selection_tests[i], i, "selection");
2214
2215 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i)
2216 RunGenerateFileNameTestCase(&generation_tests[i], i, "generation");
2217
2218 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(generation_tests); ++i) {
2219 GenerateFilenameCase test_case = generation_tests[i];
2220 test_case.referrer_charset = "GBK";
2221 RunGenerateFileNameTestCase(&test_case, i, "generation (referrer=GBK)");
1313 } 2222 }
1314 } 2223 }
1315 2224
1316 // This is currently a windows specific function. 2225 // This is currently a windows specific function.
1317 #if defined(OS_WIN) 2226 #if defined(OS_WIN)
1318 namespace { 2227 namespace {
1319 2228
1320 struct GetDirectoryListingEntryCase { 2229 struct GetDirectoryListingEntryCase {
1321 const wchar_t* name; 2230 const wchar_t* name;
1322 const char* raw_bytes; 2231 const char* raw_bytes;
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 if (it->address[i] != 0) { 3258 if (it->address[i] != 0) {
2350 all_zeroes = false; 3259 all_zeroes = false;
2351 break; 3260 break;
2352 } 3261 }
2353 } 3262 }
2354 EXPECT_FALSE(all_zeroes); 3263 EXPECT_FALSE(all_zeroes);
2355 } 3264 }
2356 } 3265 }
2357 3266
2358 } // namespace net 3267 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698