Commit e58fa0ba authored by Jungshik Shin's avatar Jungshik Shin Committed by Commit Bot

Use fromUTF8() for UnicodeString construction from UTF-8

Chrome's copy of ICU is built with U_CHARSET_IS_UTF8=1 so that |char *|
buffer is treated as UTF-8 when constructing UnicodeString() regardless
of the default encoding of the current locale on Linux or non-Unicode code
page on Windows.

However, some Linux distros do not set U_CHARSET_IS_UTF=1 when building
ICU and Chromium build with system_icu crashes when Chromium is run in
non-UTF-8 locale (e.g. 'C').

To make Chromium work in a non-UTF-8 locale (which is pretty rare these
days), use 'icu::UnicodeString::fromUTF8(StringPiece)' instead of
'icu::UnicodeString(const char*)'.

Bug: 772655
Test: components_unittests --gtest_filter=*IDN*
Test: Chromium built with system_icu does not crash in C locale.
Change-Id: I0daa284ec06b8e83814fc70eb8e9e5c96444ebfa
Reviewed-on: https://chromium-review.googlesource.com/831247Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524586}
parent 6ecf0b0c
......@@ -110,8 +110,8 @@ IDNSpoofChecker::IDNSpoofChecker() {
// These Cyrillic letters look like Latin. A domain label entirely made of
// these letters is blocked as a simplified whole-script-spoofable.
cyrillic_letters_latin_alike_ =
icu::UnicodeSet(icu::UnicodeString("[асԁеһіјӏорԛѕԝхуъЬҽпгѵѡ]"), status);
cyrillic_letters_latin_alike_ = icu::UnicodeSet(
icu::UnicodeString::fromUTF8("[асԁеһіјӏорԛѕԝхуъЬҽпгѵѡ]"), status);
cyrillic_letters_latin_alike_.freeze();
cyrillic_letters_ =
......@@ -141,8 +141,8 @@ IDNSpoofChecker::IDNSpoofChecker() {
UParseError parse_error;
diacritic_remover_.reset(icu::Transliterator::createFromRules(
UNICODE_STRING_SIMPLE("DropAcc"),
icu::UnicodeString("::NFD; ::[:Nonspacing Mark:] Remove; ::NFC;"
" ł > l; ø > o; đ > d;"),
icu::UnicodeString::fromUTF8("::NFD; ::[:Nonspacing Mark:] Remove; ::NFC;"
" ł > l; ø > o; đ > d;"),
UTRANS_FORWARD, parse_error, status));
// Supplement the Unicode confusable list by the following mapping.
......@@ -158,7 +158,7 @@ IDNSpoofChecker::IDNSpoofChecker() {
// - U+0D1F (ട) => s
extra_confusable_mapper_.reset(icu::Transliterator::createFromRules(
UNICODE_STRING_SIMPLE("ExtraConf"),
icu::UnicodeString(
icu::UnicodeString::fromUTF8(
"ӏ > l; [кĸκ] > k; п > n; [ƅь] > b; в > b; м > m; н > h; "
"т > t; [шщ] > w; ട > s;"),
UTRANS_FORWARD, parse_error, status));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment