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

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: polish Created 9 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
Index: net/ftp/ftp_util.cc
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc
index 6c7959f60f6af118cdfdd44a1c8e7948cc85f79e..286a701e185172d3f09553091e71786440468b0f 100644
--- a/net/ftp/ftp_util.cc
+++ b/net/ftp/ftp_util.cc
@@ -137,7 +137,10 @@ 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.
+ if (months[month].caseCompare(0, 3, unicode_text, 0) == 0) {
gavinp 2011/03/30 17:14:23 NIT: maybe worth noting that caseCompare works whe
Paweł Hajdan Jr. 2011/04/01 15:55:27 Done.
*number = month + 1;
return true;
}
@@ -159,6 +162,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)?

Powered by Google App Engine
This is Rietveld 408576698