Fix tonsite links.

This commit is contained in:
levlam 2024-08-17 20:07:34 +03:00
parent 13187c945a
commit 1a901a0e39
3 changed files with 4 additions and 3 deletions

View File

@ -1203,7 +1203,7 @@ Result<string> LinkManager::check_link_impl(Slice link, bool http_only, bool htt
query.remove_prefix(1);
}
for (auto c : http_url.host_) {
if (!is_alnum(c) && c != '-' && c != '_') {
if (!is_alnum(c) && c != '-' && c != '_' && !(is_tonsite && c == '.')) {
return Status::Error("Unallowed characters in URL host");
}
}

View File

@ -649,8 +649,8 @@ static vector<Slice> match_tg_urls(Slice str) {
} else if (ptr - begin >= 3 && to_lower(ptr[-3]) == 't' && to_lower(ptr[-2]) == 'o' && to_lower(ptr[-1]) == 'n') {
url_begin = ptr - 3;
} else if (ptr - begin >= 7 && to_lower(ptr[-7]) == 't' && to_lower(ptr[-6]) == 'o' && to_lower(ptr[-5]) == 'n' &&
to_lower(ptr[-5]) == 's' && to_lower(ptr[-5]) == 'i' && to_lower(ptr[-5]) == 't' &&
to_lower(ptr[-5]) == 'e') {
to_lower(ptr[-4]) == 's' && to_lower(ptr[-3]) == 'i' && to_lower(ptr[-2]) == 't' &&
to_lower(ptr[-1]) == 'e') {
url_begin = ptr - 3;
}
}

View File

@ -80,6 +80,7 @@ TEST(Link, check_link) {
check_link("..", "http://../");
check_link("https://.", "");
check_link("tOnSiTe://google", "tonsite://google/");
check_link("tOnSiTe://google.ton?t=1#we", "tonsite://google.ton?t=1#we");
}
static td::td_api::object_ptr<td::td_api::InternalLinkType> get_internal_link_type_object(