Commit b63cffc3 authored by Sujie Zhu's avatar Sujie Zhu Committed by Commit Bot

[Nickname] Fix nickname digit check

Previously we use IsAsciiDigit(char) to check whether nickname is valid.
In i18n languages, the language scripts/alphabet are encoded in Unicode.
IsAsciiDigit will mistakenly treat some i18n language scripts as digits
because Ascii is encoded in 7 bits and meant for English only, while
UTF-8 is encoded in minimum 8 bits. The influence of previous
implementation is for some of the i18n user, we won't show nickname even
if the nickname is valid (same as control group user, won't affect
user experience).

We use IsAsciiDigit(char16) instead, to check whether nickname
contains digits.

Bug: 1082013
Change-Id: I08dc77047d46225aa2f4645554e0443a800a480d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216888
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#772379}
parent 6c353381
......@@ -897,7 +897,7 @@ bool CreditCard::HasValidNickname() const {
return false;
}
// Must not contain digits.
for (char c : nickname_) {
for (base::char16 c : nickname_) {
if (base::IsAsciiDigit(c))
return false;
}
......
......@@ -61,8 +61,11 @@ const char* const kInvalidNumbers[] = {
};
const char* const kValidNicknames[] = {
"Grocery Card", "Two percent Cashback",
"Grocery Card",
"Two percent Cashback",
"Mastercard \xF0\x9F\x92\xB3", /* Nickname with UTF-8 hex encoded emoji */
"\u0634\u063a\u0645\u0688", /* arbitrary Arabic script in unicode */
"\u0434\u0444\u0431\u044A", /* arbitrary Cyrillic script in unicode */
};
const char* const kInvalidNicknames[] = {
......
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