Increase maximum allowed TLD length in email address.

This commit is contained in:
levlam 2022-01-30 13:51:28 +03:00
parent 462797b48a
commit d3c712e660
3 changed files with 5 additions and 4 deletions

View File

@ -134,7 +134,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
// video animation
video = nullptr;
}
} else if (sticker != nullptr) {
} else if (sticker != nullptr && false) {
// some stickers uploaded before release
type_attributes--;
video = nullptr;

View File

@ -929,7 +929,7 @@ static bool is_valid_bank_card(Slice str) {
}
bool is_email_address(Slice str) {
// /^([a-z0-9_-]{0,26}[.+]){0,10}[a-z0-9_-]{1,35}@(([a-z0-9][a-z0-9_-]{0,28})?[a-z0-9][.]){1,6}[a-z]{2,6}$/i
// /^([a-z0-9_-]{0,26}[.+]){0,10}[a-z0-9_-]{1,35}@(([a-z0-9][a-z0-9_-]{0,28})?[a-z0-9][.]){1,6}[a-z]{2,8}$/i
Slice userdata;
Slice domain;
std::tie(userdata, domain) = split(str, '@');
@ -966,7 +966,7 @@ bool is_email_address(Slice str) {
if (domain_parts.size() <= 1 || domain_parts.size() > 7) {
return false;
}
if (domain_parts.back().size() <= 1 || domain_parts.back().size() >= 7) {
if (domain_parts.back().size() <= 1 || domain_parts.back().size() >= 9) {
return false;
}
for (auto c : domain_parts.back()) {

View File

@ -373,7 +373,7 @@ TEST(MessageEntities, is_email_address) {
"a.a.a.a.a.a+ab",
"a+a.a.a.a.a.ab",
"a.a.a.a.a.a.a",
"a.a.a.a.a.a.abcdefg",
"a.a.a.a.a.a.abcdefghi",
"a.a.a.a.a.a.ab0yz",
"a.a.a.a.a.a.ab9yz",
"a.a.a.a.a.a.ab-yz",
@ -694,6 +694,7 @@ TEST(MessageEntities, url) {
check_url("http://google.com/‖", {"http://google.com/"});
check_url("a@b@c.com", {}, {});
check_url("a@b.com:c@1", {}, {"a@b.com"});
check_url("test@test.software", {}, {"test@test.software"});
}
static void check_fix_formatted_text(td::string str, td::vector<td::MessageEntity> entities,