Check the URL in IV like in attach bots.

This commit is contained in:
John Preston 2024-04-06 22:56:13 +04:00
parent 7803f8e670
commit eaaa704fa4
2 changed files with 12 additions and 5 deletions

View File

@ -838,6 +838,9 @@ void Instance::show(
_shownSession = session;
_shown->events() | rpl::start_with_next([=](Controller::Event event) {
using Type = Controller::Event::Type;
const auto lower = event.url.toLower();
const auto urlChecked = lower.startsWith("http://")
|| lower.startsWith("https://");
switch (event.type) {
case Type::Close:
_shown = nullptr;
@ -852,7 +855,9 @@ void Instance::show(
processJoinChannel(event.context);
break;
case Type::OpenLinkExternal:
File::OpenUrl(event.url);
if (urlChecked) {
File::OpenUrl(event.url);
}
closeAll();
break;
case Type::OpenMedia:
@ -891,6 +896,9 @@ void Instance::show(
break;
case Type::OpenPage:
case Type::OpenLink:
if (!urlChecked) {
break;
}
_shownSession->api().request(MTPmessages_GetWebPage(
MTP_string(event.url),
MTP_int(0)

View File

@ -800,12 +800,11 @@ void Panel::openExternalLink(const QJsonObject &args) {
_delegate->botClose();
return;
}
const auto url = args["url"].toString();
const auto iv = args["try_instant_view"].toBool();
const auto url = args["url"].toString();
const auto lower = url.toLower();
if (url.isEmpty()
|| (!lower.startsWith("http://") && !lower.startsWith("https://"))) {
LOG(("BotWebView Error: Bad 'url' in openExternalLink."));
if (!lower.startsWith("http://") && !lower.startsWith("https://")) {
LOG(("BotWebView Error: Bad url in openExternalLink: %1").arg(url));
_delegate->botClose();
return;
} else if (!allowOpenLink()) {