diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index e7f34dea8..43fed746f 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -748,23 +748,12 @@ static vector match_urls(Slice str) { const unsigned char *last_at_ptr = nullptr; const unsigned char *domain_end_ptr = begin + dot_pos; - if (domain_begin_ptr == begin || domain_begin_ptr[-1] != '@') { - // try to find '@' to the right if there is no '@' to the left - while (domain_end_ptr != end) { - uint32 code = 0; - auto next_ptr = next_utf8_unsafe(domain_end_ptr, &code); - if (code == '@') { - last_at_ptr = domain_end_ptr; - } else if (!is_domain_symbol(code)) { - break; - } - domain_end_ptr = next_ptr; - } - } while (domain_end_ptr != end) { uint32 code = 0; auto next_ptr = next_utf8_unsafe(domain_end_ptr, &code); - if (!is_domain_symbol(code)) { + if (code == '@') { + last_at_ptr = domain_end_ptr; + } else if (!is_domain_symbol(code)) { break; } domain_end_ptr = next_ptr; diff --git a/test/message_entities.cpp b/test/message_entities.cpp index 47b590a76..905cac0fc 100644 --- a/test/message_entities.cpp +++ b/test/message_entities.cpp @@ -704,6 +704,7 @@ TEST(MessageEntities, url) { check_url("http://test―‑@―google―.―com―/―–―‐―/―/―/―?―‑―#―――", {"http://test―‑@―google―.―com―/―–―‐―/―/―/―?―‑―#―――"}); check_url("http://google.com/‖", {"http://google.com/"}); check_url("a@b@c.com", {}, {}); + check_url("abc@c.com@d.com", {}); check_url("a@b.com:c@1", {}, {"a@b.com"}); check_url("test@test.software", {}, {"test@test.software"}); check_url("a:b?@gmail.com", {});