From 4cb11e34765bf180abc25bfc38d779a7ef5c6d6e Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 13 Oct 2015 22:48:46 +0200 Subject: [PATCH] Added hidden url confirm --- app/js/lib/ng_utils.js | 5 ++++- app/js/locales/en-us.json | 1 + app/js/services.js | 14 +++++++++++++- app/partials/desktop/confirm_modal.html | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index 74809549..4377e44f 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -1532,7 +1532,10 @@ angular.module('izhukov.utils', []) url = 'http://' + url; } var tgMeMatch; - if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) { + if (entity._ == 'messageEntityTextUrl') { + url = 'tg://unsafe_url?url=' + encodeURIComponent(url); + } + else if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) { var path = tgMeMatch[1].split('/'); switch (path[0]) { case 'joinchat': diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 5723bf44..ceefa955 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -222,6 +222,7 @@ "confirm_modal_revoke_group_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the group using it.", "confirm_modal_revoke_channel_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the channel using it.", "confirm_modal_delete_channel_md": "Are you sure you want to delete this channel?\n\nAll members will be removed and all messages will be lost.", + "confirm_modal_jump_ext_url_md": "Open this link?\n\n{url}", "confirm_modal_are_u_sure": "Are you sure?", diff --git a/app/js/services.js b/app/js/services.js index e3c6d270..edee1f16 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -3684,7 +3684,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }) -.service('LocationParamsService', function ($rootScope, $routeParams, AppPeersManager, AppUsersManager, AppMessagesManager, PeersSelectService, AppStickersManager) { +.service('LocationParamsService', function ($rootScope, $routeParams, AppPeersManager, AppUsersManager, AppMessagesManager, PeersSelectService, AppStickersManager, ErrorService) { var tgAddrRegExp = /^(web\+)?tg:(\/\/)?(.+)/; @@ -3750,6 +3750,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return true; } + if (inner && + (matches = url.match(/^unsafe_url\?url=([^&]+)/))) { + var url = decodeURIComponent(matches[1]); + ErrorService.confirm({ + type: 'JUMP_EXT_URL', + url: url + }).then(function () { + window.open(url, '_blank'); + }); + return true; + } + if (inner && (matches = url.match(/^bot_command\?command=(.+?)(?:&bot=(.+))?$/))) { diff --git a/app/partials/desktop/confirm_modal.html b/app/partials/desktop/confirm_modal.html index 2e4374cc..6c20b7ee 100644 --- a/app/partials/desktop/confirm_modal.html +++ b/app/partials/desktop/confirm_modal.html @@ -55,6 +55,9 @@
+
+ +