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

Unified Diff: net/ftp/ftp_util.cc

Issue 6718043: FTP: Multiple fixes for localized directory listings: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update copyright year for the bot Created 9 years, 8 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_unittest.cc ('k') | net/ftp/ftp_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_util.cc
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc
index abbeeda38f183a43c6bf15c6652aaa715f3e180c..441c666217b3123c9a798599e4756bd147187f6b 100644
--- a/net/ftp/ftp_util.cc
+++ b/net/ftp/ftp_util.cc
@@ -139,7 +139,12 @@ bool FtpUtil::AbbreviatedMonthToNumber(const string16& text, int* number) {
// An alternative solution (to parse |text| in given locale) is more
// lenient, and may accept more than we want even with setLenient(false).
for (int32_t month = 0; month < months_count; month++) {
- if (months[month].caseCompare(unicode_text, 0) == 0) {
+ // Compare (case-insensitive), but just first three characters. Sometimes
+ // ICU returns longer strings (for example for Russian locale), and in FTP
+ // listings they are abbreviated to just three characters.
+ // Note: ICU may also return strings shorter than three characters,
+ // and those also should be accepted.
+ if (months[month].caseCompare(0, 3, unicode_text, 0) == 0) {
*number = month + 1;
return true;
}
@@ -161,6 +166,8 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day,
if (!base::StringToInt(day, &time_exploded.day_of_month))
return false;
+ if (time_exploded.day_of_month > 31)
+ return false;
if (!base::StringToInt(rest, &time_exploded.year)) {
// Maybe it's time. Does it look like time (HH:MM)?
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_unittest.cc ('k') | net/ftp/ftp_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698