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