Do not highlight parts of float numbers as bank card numbers.

GitOrigin-RevId: cc58f030c6485c393f115fb89a4e9a5b2e6b40b9
This commit is contained in:
levlam 2020-05-07 23:11:54 +03:00
parent f2cb3afaef
commit f88735b9a9
2 changed files with 4 additions and 4 deletions

View File

@ -422,7 +422,7 @@ static vector<Slice> match_bank_card_numbers(Slice str) {
const unsigned char *end = str.uend();
const unsigned char *ptr = begin;
// '/(?<=^|[^+_\pL\d-])[\d -]{13,}([^_\pL\d-]|$)/'
// '/(?<=^|[^+_\pL\d-.,])[\d -]{13,}([^_\pL\d-]|$)/'
while (true) {
while (ptr != end && !is_digit(*ptr)) {
@ -435,7 +435,7 @@ static vector<Slice> match_bank_card_numbers(Slice str) {
uint32 prev;
next_utf8_unsafe(prev_utf8_unsafe(ptr), &prev, "match_bank_card_numbers");
if (prev == '+' || prev == '-' || prev == '_' ||
if (prev == '.' || prev == ',' || prev == '+' || prev == '-' || prev == '_' ||
get_unicode_simple_category(prev) == UnicodeSimpleCategory::Letter) {
while (ptr != end && (is_digit(*ptr) || *ptr == ' ' || *ptr == '-')) {
ptr++;

View File

@ -201,7 +201,7 @@ TEST(MessageEntities, bank_card_number) {
check_bank_card_number(" - - - - 1 - -- 234 - - 56- - 7890150000 - - - -", {"1 - -- 234 - - 56- - 7890150000"});
check_bank_card_number("4916-3385-0608-2832; 5280 9342 8317 1080 ;345936346788903",
{"4916-3385-0608-2832", "5280 9342 8317 1080", "345936346788903"});
check_bank_card_number("4556728228023269,4916141675244747020,49161416752447470,4556728228023269",
check_bank_card_number("4556728228023269, 4916141675244747020, 49161416752447470, 4556728228023269",
{"4556728228023269", "4916141675244747020", "4556728228023269"});
check_bank_card_number("a1234567890128", {});
check_bank_card_number("1234567890128a", {});
@ -210,7 +210,7 @@ TEST(MessageEntities, bank_card_number) {
check_bank_card_number("1234567890128_", {});
check_bank_card_number("_1234567890128", {});
check_bank_card_number("1234567890128/", {"1234567890128"});
check_bank_card_number(",1234567890128", {"1234567890128"});
check_bank_card_number("\"1234567890128", {"1234567890128"});
check_bank_card_number("+1234567890128", {});
}