Disable SFTP link highlighting.

This commit is contained in:
levlam 2021-02-03 21:08:01 +03:00
parent 8146ecf950
commit b07a9efb2e
2 changed files with 3 additions and 6 deletions

View File

@ -677,9 +677,7 @@ static vector<Slice> 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;

View File

@ -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"});