Use case-insensitive comparison for short mention entities.
This commit is contained in:
parent
70b71d569b
commit
f0e7b211c3
@ -1126,7 +1126,8 @@ vector<Slice> find_mentions(Slice str) {
|
||||
if (mention.size() >= 5) {
|
||||
return false;
|
||||
}
|
||||
return get_valid_short_usernames().count(mention) == 0;
|
||||
auto lowered_mention = to_lower(mention);
|
||||
return get_valid_short_usernames().count(lowered_mention) == 0;
|
||||
});
|
||||
return mentions;
|
||||
}
|
||||
|
@ -44,8 +44,9 @@ TEST(MessageEntities, mention) {
|
||||
check_mention("@abcdefghijklmnopqrstuvwxyz123456", {"@abcdefghijklmnopqrstuvwxyz123456"});
|
||||
check_mention("@abcdefghijklmnopqrstuvwxyz1234567", {});
|
||||
check_mention("нет@mention", {});
|
||||
check_mention("@ya @gif @wiki @vid @bing @pic @bold @imdb @coub @like @vote @giff @cap ya cap @y @yar @bingg @bin",
|
||||
{"@gif", "@wiki", "@vid", "@bing", "@pic", "@bold", "@imdb", "@coub", "@like", "@vote", "@bingg"});
|
||||
check_mention(
|
||||
"@ya @gif @wiki @vid @bing @pic @bold @imdb @ImDb @coub @like @vote @giff @cap ya cap @y @yar @bingg @bin",
|
||||
{"@gif", "@wiki", "@vid", "@bing", "@pic", "@bold", "@imdb", "@ImDb", "@coub", "@like", "@vote", "@bingg"});
|
||||
};
|
||||
|
||||
static void check_bot_command(const td::string &str, const td::vector<td::string> &expected) {
|
||||
|
Loading…
Reference in New Issue
Block a user