From 8acf0684c77f98854507470b8da2f294772295bd Mon Sep 17 00:00:00 2001
From: "phajdan.jr@chromium.org"
<phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Sat, 9 Apr 2011 09:58:33 +0000
Subject: FTP: fix a misuse of isspace (it can only operate on char, not
char16; this triggers an assertion on Windows, see
http://codereview.chromium.org/6802006/ and
http://msdn.microsoft.com/en-us/library/y13z34da(v=vs.71).aspx)
This change replaces isspace with ICU's u_isspace.
The original problem was introduced by http://codereview.chromium.org/449011/
The problem was detected while landing http://codereview.chromium.org/6718043,
which adds more tests with non-ASCII characters.
BUG=none
Review URL: http://codereview.chromium.org/6802012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81037 0039d316-1c4b-4281-b951-d872f2087c98
---
net/ftp/ftp_util.cc | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
(limited to 'net/ftp')
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc
index 6c7959f..abbeeda 100644
--- a/net/ftp/ftp_util.cc
+++ b/net/ftp/ftp_util.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "base/i18n/char_iterator.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/string_tokenizer.h"
@@ -14,6 +15,7 @@
#include "base/utf_string_conversions.h"
#include "unicode/datefmt.h"
#include "unicode/dtfmtsym.h"
+#include "unicode/uchar.h"
// For examples of Unix<->VMS path conversions, see the unit test file. On VMS
// a path looks differently depending on whether it's a file or directory.
@@ -209,19 +211,20 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day,
// static
string16 FtpUtil::GetStringPartAfterColumns(const string16& text, int columns) {
- size_t pos = 0;
+ base::i18n::UTF16CharIterator iter(&text);
+ // TODO(jshin): Is u_isspace the right function to use here?
for (int i = 0; i < columns; i++) {
// Skip the leading whitespace.
- while (pos < text.length() && isspace(text[pos]))
- pos++;
+ while (!iter.end() && u_isspace(iter.get()))
+ iter.Advance();
// Skip the actual text of i-th column.
- while (pos < text.length() && !isspace(text[pos]))
- pos++;
+ while (!iter.end() && !u_isspace(iter.get()))
+ iter.Advance();
}
- string16 result(text.substr(pos));
+ string16 result(text.substr(iter.array_pos()));
TrimWhitespace(result, TRIM_ALL, &result);
return result;
}
--
cgit v1.1