diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 09:29:54 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 09:29:54 +0000 |
commit | 82acbaaacf50d6ac2db1e810839939a278e96833 (patch) | |
tree | b9261734f168f2d5b9e8b8c3876e56465bc898a3 /net/ftp/ftp_util.cc | |
parent | 702b14e4f040653f9580644dfb8494659f210a57 (diff) | |
download | chromium_src-82acbaaacf50d6ac2db1e810839939a278e96833.zip chromium_src-82acbaaacf50d6ac2db1e810839939a278e96833.tar.gz chromium_src-82acbaaacf50d6ac2db1e810839939a278e96833.tar.bz2 |
FTP: Multiple fixes for localized directory listings:
- fix detection of KOI8-R and possibly other encodings
- fix parsing Russian month names
When detecting the listing encoding, we need to not only
check whether the data can be converted using given encoding,
but also whether the result can be parsed as a valid directory listing.
Also, we only need to compare the first three characters of the
abbreviated month name, because that's how they're abbreviated
in FTP directory listings.
Finally, the Russian directory listings have swapped the "month" and "day of month" columns.
BUG=65917
Review URL: http://codereview.chromium.org/6718043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_util.cc')
-rw-r--r-- | net/ftp/ftp_util.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index abbeeda..441c666 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)? |