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

Unified Diff: net/ftp/ftp_directory_listing_parser_unittest.cc

Issue 11470035: FTP: correctly handle newlines in file names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed \r Created 8 years 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/ftp/ftp_directory_listing_parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_parser_unittest.cc b/net/ftp/ftp_directory_listing_parser_unittest.cc
index 02f13921595fb9c8765dcccaf9bdd08b881db31c..434cdfaf5e3506aa4f37850a882b1edc53146279 100644
--- a/net/ftp/ftp_directory_listing_parser_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_unittest.cc
@@ -9,7 +9,7 @@
#include "base/path_service.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
-#include "base/string_tokenizer.h"
+#include "base/string_split.h"
#include "base/utf_string_conversions.h"
#include "net/base/net_errors.h"
#include "net/ftp/ftp_directory_listing_parser.h"
@@ -56,26 +56,28 @@ TEST_P(FtpDirectoryListingParserTest, Parse) {
&expected_listing));
std::vector<std::string> lines;
- StringTokenizer tokenizer(expected_listing, "\r\n");
- while (tokenizer.GetNext())
- lines.push_back(tokenizer.token());
+ base::SplitStringUsingSubstr(expected_listing, "\r\n", &lines);
- ASSERT_EQ(8 * entries.size(), lines.size());
+ // Special case for empty listings.
+ if (lines.size() == 1 && lines[0].empty())
+ lines.clear();
- for (size_t i = 0; i < lines.size() / 8; i++) {
- std::string type(lines[8 * i]);
- std::string name(lines[8 * i + 1]);
+ ASSERT_EQ(9 * entries.size(), lines.size());
+
+ for (size_t i = 0; i < lines.size() / 9; i++) {
+ std::string type(lines[9 * i]);
+ std::string name(lines[9 * i + 1]);
int64 size;
- base::StringToInt64(lines[8 * i + 2], &size);
+ base::StringToInt64(lines[9 * i + 2], &size);
SCOPED_TRACE(base::StringPrintf("Filename: %s", name.c_str()));
int year, month, day_of_month, hour, minute;
- base::StringToInt(lines[8 * i + 3], &year);
- base::StringToInt(lines[8 * i + 4], &month);
- base::StringToInt(lines[8 * i + 5], &day_of_month);
- base::StringToInt(lines[8 * i + 6], &hour);
- base::StringToInt(lines[8 * i + 7], &minute);
+ base::StringToInt(lines[9 * i + 3], &year);
+ base::StringToInt(lines[9 * i + 4], &month);
+ base::StringToInt(lines[9 * i + 5], &day_of_month);
+ base::StringToInt(lines[9 * i + 6], &hour);
+ base::StringToInt(lines[9 * i + 7], &minute);
const FtpDirectoryListingEntry& entry = entries[i];
@@ -138,6 +140,7 @@ const char* kTestFiles[] = {
"dir-listing-ls-28", // Hylafax FTP server
"dir-listing-ls-29",
"dir-listing-ls-30",
+ "dir-listing-ls-31",
"dir-listing-netware-1",
"dir-listing-netware-2",
« no previous file with comments | « net/ftp/ftp_directory_listing_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698