2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Add a confirmation for internal passport links.

Fixes #5020.
This commit is contained in:
John Preston
2018-07-31 20:56:54 +03:00
parent 9972f7b90e
commit ae272074b9
4 changed files with 34 additions and 12 deletions

View File

@@ -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(