diff options
author | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 21:42:00 +0000 |
---|---|---|
committer | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 21:42:00 +0000 |
commit | c9ec45429c64884c35f83b74131c0e3ae5b2bbe9 (patch) | |
tree | 39007373603b8e75f53fa5e4d0c1586b1a3a56b5 /net | |
parent | 7e2fa03804bef4bff9c5bb941f2edf09b6d234c0 (diff) | |
download | chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.zip chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.tar.gz chromium_src-c9ec45429c64884c35f83b74131c0e3ae5b2bbe9.tar.bz2 |
Add UTF-8 check for JSON deserializer.
Add tests for IsStringUTF8
Make IsStringUTF8 accept std::string/std::wstring rather than char*/wchar_t*
Review URL: http://codereview.chromium.org/4268
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/net_util.cc | 4 | ||||
-rw-r--r-- | net/base/net_util_win.cc | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index d3075ad..305cbcc 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -237,7 +237,7 @@ bool DecodeWord(const std::string& encoded_word, // UTF-16 assuming it's in the OS default encoding. if (!IsStringASCII(encoded_word)) { // Try falling back to the NativeMB encoding if the raw input is not UTF-8. - if (IsStringUTF8(encoded_word.c_str())) { + if (IsStringUTF8(encoded_word)) { *output = encoded_word; } else { *output = WideToUTF8(base::SysNativeMBToWide(encoded_word)); @@ -328,7 +328,7 @@ bool DecodeWord(const std::string& encoded_word, // support a rudimentary form of RFC 2231 with charset label, but // it'd gain us little in terms of compatibility. tmp = UnescapeURLComponent(encoded_word, UnescapeRule::SPACES); - if (IsStringUTF8(tmp.c_str())) { + if (IsStringUTF8(tmp)) { output->swap(tmp); return true; // We can try either the OS default charset or 'origin charset' here, diff --git a/net/base/net_util_win.cc b/net/base/net_util_win.cc index 206f485..7ea217c 100644 --- a/net/base/net_util_win.cc +++ b/net/base/net_util_win.cc @@ -44,7 +44,7 @@ bool FileURLToFilePath(const GURL& url, std::wstring* file_path) { path = UnescapeURLComponent(path, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); - if (!IsStringUTF8(path.c_str())) { + if (!IsStringUTF8(path)) { // Not UTF-8, assume encoding is native codepage and we're done. We know we // are giving the conversion function a nonempty string, and it may fail if // the given string is not in the current encoding and give us an empty @@ -68,7 +68,7 @@ bool FileURLToFilePath(const GURL& url, std::wstring* file_path) { NOTREACHED() << "Should have filtered out non-8-bit strings above."; return false; } - if (IsStringUTF8(narrow.c_str())) { + if (IsStringUTF8(narrow)) { // Our string actually looks like it could be UTF-8, convert to 8-bit // UTF-8 and then to the corresponding wide string. *file_path = UTF8ToWide(narrow); |