diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index ec8a7dda8..9a4c0be62 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -677,9 +677,7 @@ static vector match_urls(Slice str) { url_begin_ptr = url_begin_ptr - 7; } else if (ends_with(protocol, "https")) { url_begin_ptr = url_begin_ptr - 8; - } else if (ends_with(protocol, "sftp")) { - url_begin_ptr = url_begin_ptr - 7; - } else if (ends_with(protocol, "ftp") && protocol != "tftp") { + } else if (ends_with(protocol, "ftp") && protocol != "tftp" && protocol != "sftp") { url_begin_ptr = url_begin_ptr - 6; } else { is_bad = true; @@ -983,8 +981,7 @@ Slice fix_url(Slice str) { bool has_protocol = false; auto str_begin = to_lower(str.substr(0, 8)); - if (begins_with(str_begin, "http://") || begins_with(str_begin, "https://") || begins_with(str_begin, "sftp://") || - begins_with(str_begin, "ftp://")) { + if (begins_with(str_begin, "http://") || begins_with(str_begin, "https://") || begins_with(str_begin, "ftp://")) { auto pos = str.find(':'); str = str.substr(pos + 3); has_protocol = true; diff --git a/test/message_entities.cpp b/test/message_entities.cpp index b9636fa51..d65bc320f 100644 --- a/test/message_entities.cpp +++ b/test/message_entities.cpp @@ -381,7 +381,7 @@ TEST(MessageEntities, url) { check_url("http://telegram.org", {"http://telegram.org"}); check_url("ftp://telegram.org", {"ftp://telegram.org"}); check_url("ftps://telegram.org", {}); - check_url("sftp://telegram.org", {"sftp://telegram.org"}); + check_url("sftp://telegram.org", {}); check_url("hTtPs://telegram.org", {"hTtPs://telegram.org"}); check_url("HTTP://telegram.org", {"HTTP://telegram.org"}); check_url("аHTTP://telegram.org", {"HTTP://telegram.org"});