mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 03:50:43 +00:00
parent
9972f7b90e
commit
ae272074b9
@ -1041,6 +1041,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_open_this_link" = "Open this link?";
|
||||
"lng_open_link" = "Open";
|
||||
"lng_open_passport_link" = "Open this Telegram Passport authorization?";
|
||||
"lng_allow_bot_pass" = "Allow {bot_name} to pass your Telegram name and ID to the web pages you open via this bot?";
|
||||
"lng_allow_bot" = "Allow";
|
||||
|
||||
|
@ -64,11 +64,10 @@ QString _escapeFrom7bit(const QString &str) {
|
||||
|
||||
} // namespace
|
||||
|
||||
bool StartUrlRequiresActivate(const QString &url) {
|
||||
bool InternalPassportLink(const QString &url) {
|
||||
const auto urlTrimmed = url.trimmed();
|
||||
if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)
|
||||
|| Messenger::Instance().locked()) {
|
||||
return true;
|
||||
if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
||||
return false;
|
||||
}
|
||||
const auto command = urlTrimmed.midRef(qstr("tg://").size());
|
||||
|
||||
@ -78,11 +77,23 @@ bool StartUrlRequiresActivate(const QString &url) {
|
||||
qsl("^passport/?\\?(.+)(#|$)"),
|
||||
command,
|
||||
matchOptions);
|
||||
const auto authLegacyMatch = regex_match(
|
||||
qsl("^resolve/?\\?domain=telegrampassport&(.+)(#|$)"),
|
||||
const auto usernameMatch = regex_match(
|
||||
qsl("^resolve/?\\?(.+)(#|$)"),
|
||||
command,
|
||||
matchOptions);
|
||||
return !authMatch->hasMatch() && !authLegacyMatch->hasMatch();
|
||||
const auto usernameValue = usernameMatch->hasMatch()
|
||||
? url_parse_params(
|
||||
usernameMatch->captured(1),
|
||||
UrlParamNameTransform::ToLower).value(qsl("domain"))
|
||||
: QString();
|
||||
const auto authLegacy = (usernameValue == qstr("telegrampassport"));
|
||||
return authMatch->hasMatch() || authLegacy;
|
||||
}
|
||||
|
||||
bool StartUrlRequiresActivate(const QString &url) {
|
||||
return Messenger::Instance().locked()
|
||||
? true
|
||||
: !InternalPassportLink(url);
|
||||
}
|
||||
|
||||
Application::Application(
|
||||
|
@ -12,6 +12,7 @@ class Launcher;
|
||||
class UpdateChecker;
|
||||
} // namespace Core
|
||||
|
||||
bool InternalPassportLink(const QString &url);
|
||||
bool StartUrlRequiresActivate(const QString &url);
|
||||
|
||||
class Application : public QApplication {
|
||||
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "messenger.h"
|
||||
#include "application.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/history_item.h"
|
||||
@ -142,13 +143,21 @@ TextWithEntities UrlClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMod
|
||||
|
||||
void HiddenUrlClickHandler::Open(QString url, QVariant context) {
|
||||
auto urlText = tryConvertUrlToLocal(url);
|
||||
|
||||
const auto open = [=] {
|
||||
UrlClickHandler::Open(urlText, context);
|
||||
};
|
||||
if (urlText.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
||||
Messenger::Instance().openLocalUrl(urlText, context);
|
||||
if (InternalPassportLink(urlText)) {
|
||||
Ui::show(
|
||||
Box<ConfirmBox>(
|
||||
lang(lng_open_passport_link),
|
||||
lang(lng_open_link),
|
||||
[=] { Ui::hideLayer(); open(); }),
|
||||
LayerOption::KeepOther);
|
||||
} else {
|
||||
open();
|
||||
}
|
||||
} else {
|
||||
const auto open = [=] {
|
||||
UrlClickHandler::Open(urlText, context);
|
||||
};
|
||||
auto parsedUrl = QUrl::fromUserInput(urlText);
|
||||
if (UrlRequiresConfirmation(urlText)) {
|
||||
auto displayUrl = parsedUrl.isValid()
|
||||
|
Loading…
Reference in New Issue
Block a user