OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/ftp/ftp_util.h" | 5 #include "net/ftp/ftp_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 month_name = base::i18n::ToLower(month_name); | 180 month_name = base::i18n::ToLower(month_name); |
181 | 181 |
182 map_[month_name] = month + 1; | 182 map_[month_name] = month + 1; |
183 | 183 |
184 // Sometimes ICU returns longer strings, but in FTP listings a shorter | 184 // Sometimes ICU returns longer strings, but in FTP listings a shorter |
185 // abbreviation is used (for example for the Russian locale). Make sure | 185 // abbreviation is used (for example for the Russian locale). Make sure |
186 // we always have a map entry for a three-letter abbreviation. | 186 // we always have a map entry for a three-letter abbreviation. |
187 map_[month_name.substr(0, 3)] = month + 1; | 187 map_[month_name.substr(0, 3)] = month + 1; |
188 } | 188 } |
189 } | 189 } |
| 190 |
| 191 // Fail loudly if the data returned by ICU is obviously incomplete. |
| 192 // This is intended to catch cases like http://crbug.com/177428 |
| 193 // much earlier. Note that the issue above turned out to be non-trivial |
| 194 // to reproduce - crash data is much better indicator of a problem |
| 195 // than incomplete bug reports. |
| 196 CHECK_EQ(1, map_[ASCIIToUTF16("jan")]); |
| 197 CHECK_EQ(2, map_[ASCIIToUTF16("feb")]); |
| 198 CHECK_EQ(3, map_[ASCIIToUTF16("mar")]); |
| 199 CHECK_EQ(4, map_[ASCIIToUTF16("apr")]); |
| 200 CHECK_EQ(5, map_[ASCIIToUTF16("may")]); |
| 201 CHECK_EQ(6, map_[ASCIIToUTF16("jun")]); |
| 202 CHECK_EQ(7, map_[ASCIIToUTF16("jul")]); |
| 203 CHECK_EQ(8, map_[ASCIIToUTF16("aug")]); |
| 204 CHECK_EQ(9, map_[ASCIIToUTF16("sep")]); |
| 205 CHECK_EQ(10, map_[ASCIIToUTF16("oct")]); |
| 206 CHECK_EQ(11, map_[ASCIIToUTF16("nov")]); |
| 207 CHECK_EQ(12, map_[ASCIIToUTF16("dec")]); |
190 } | 208 } |
191 | 209 |
192 // Maps lowercase month names to numbers in range 1-12. | 210 // Maps lowercase month names to numbers in range 1-12. |
193 std::map<base::string16, int> map_; | 211 std::map<base::string16, int> map_; |
194 | 212 |
195 DISALLOW_COPY_AND_ASSIGN(AbbreviatedMonthsMap); | 213 DISALLOW_COPY_AND_ASSIGN(AbbreviatedMonthsMap); |
196 }; | 214 }; |
197 | 215 |
198 } // namespace | 216 } // namespace |
199 | 217 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 while (!iter.end() && !u_isspace(iter.get())) | 367 while (!iter.end() && !u_isspace(iter.get())) |
350 iter.Advance(); | 368 iter.Advance(); |
351 } | 369 } |
352 | 370 |
353 base::string16 result(text.substr(iter.array_pos())); | 371 base::string16 result(text.substr(iter.array_pos())); |
354 TrimWhitespace(result, TRIM_ALL, &result); | 372 TrimWhitespace(result, TRIM_ALL, &result); |
355 return result; | 373 return result; |
356 } | 374 } |
357 | 375 |
358 } // namespace | 376 } // namespace |
OLD | NEW |