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

Unified Diff: net/ftp/ftp_directory_listing_parser_ls.cc

Issue 1120012: Fix the "ls -l" style date parser to correctly guess the year if it is not provided. (Closed)
Patch Set: better comments Created 10 years, 9 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/ftp/ftp_directory_listing_parser_ls.h ('k') | net/ftp/ftp_directory_listing_parser_ls_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser_ls.cc
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index 1098cdac68c9568ec84859bba988e7bf1f7a6eb0..55f784482380f636395d2926d5903cc54528282f 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -42,12 +42,13 @@ bool LooksLikeUnixPermissionsListing(const string16& text) {
(text.substr(10).empty() || text.substr(10) == ASCIIToUTF16("+")));
}
-bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
+bool DetectColumnOffset(const std::vector<string16>& columns,
+ const base::Time& current_time, int* offset) {
base::Time time;
if (columns.size() >= 8 &&
net::FtpUtil::LsDateListingToTime(columns[5], columns[6], columns[7],
- &time)) {
+ current_time, &time)) {
// Standard listing, exactly like ls -l.
*offset = 2;
return true;
@@ -55,7 +56,7 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
if (columns.size() >= 7 &&
net::FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6],
- &time)) {
+ current_time, &time)) {
// wu-ftpd listing, no "number of links" column.
*offset = 1;
return true;
@@ -63,7 +64,7 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
if (columns.size() >= 6 &&
net::FtpUtil::LsDateListingToTime(columns[3], columns[4], columns[5],
- &time)) {
+ current_time, &time)) {
// Xplain FTP Server listing for folders, like this:
// drwxr-xr-x folder 0 Jul 17 2006 online
*offset = 0;
@@ -78,9 +79,11 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
namespace net {
-FtpDirectoryListingParserLs::FtpDirectoryListingParserLs()
+FtpDirectoryListingParserLs::FtpDirectoryListingParserLs(
+ const base::Time& current_time)
: received_nonempty_line_(false),
- received_total_line_(false) {
+ received_total_line_(false),
+ current_time_(current_time) {
}
bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
@@ -113,7 +116,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
}
int column_offset;
- if (!DetectColumnOffset(columns, &column_offset))
+ if (!DetectColumnOffset(columns, current_time_, &column_offset))
return false;
// We may receive file names containing spaces, which can make the number of
@@ -144,6 +147,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
if (!FtpUtil::LsDateListingToTime(columns[3 + column_offset],
columns[4 + column_offset],
columns[5 + column_offset],
+ current_time_,
&entry.last_modified)) {
return false;
}
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.h ('k') | net/ftp/ftp_directory_listing_parser_ls_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698