From b8815e2cf78f7ee050aaeb21e7c17aba177b8a87 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 20 Mar 2017 23:44:59 +0800 Subject: [PATCH] new task command api check whether specified url is base64 encoded --- src/langs/zh_CN.txt | 1 + src/scripts/config/defaultLanguage.js | 1 + src/scripts/controllers/command.js | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/langs/zh_CN.txt b/src/langs/zh_CN.txt index 6925c6e..7814947 100644 --- a/src/langs/zh_CN.txt +++ b/src/langs/zh_CN.txt @@ -186,6 +186,7 @@ Input value is invalid!=输入的内容无效! Protocol is invalid!=协议无效! RPC host cannot be empty!=RPC 主机不能为空! RPC secret is not base64 encoded!=RPC 密钥不是 Base64 编码后的字符串! +URL is not base64 encoded!=指定 URL 不是 Base64 编码后的字符串! Tap to configure and get started with AriaNg.=您还没有进行过设置, 点击这里进行设置. [error] diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index 88c0ca0..9d9bf7e 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -190,6 +190,7 @@ 'Protocol is invalid!': 'Protocol is invalid!', 'RPC host cannot be empty!': 'RPC host cannot be empty!', 'RPC secret is not base64 encoded!': 'RPC secret is not base64 encoded!', + 'URL is not base64 encoded!': 'URL is not base64 encoded!', 'Tap to configure and get started with AriaNg.': 'Tap to configure and get started with AriaNg.', 'error': { 'unknown': 'Unknown error occurred.', diff --git a/src/scripts/controllers/command.js b/src/scripts/controllers/command.js index 889b886..fcf214c 100644 --- a/src/scripts/controllers/command.js +++ b/src/scripts/controllers/command.js @@ -19,7 +19,15 @@ if (path.indexOf('/new/') === 0) { var base64Url = $routeParams.url; - var url = base64.urldecode(base64Url); + var url = base64Url; + + try { + url = base64.urldecode(base64Url); + } catch (ex) { + ariaNgCommonService.showError('URL is not base64 encoded!'); + return; + } + $rootScope.loadPromise = newUrlDownload(url); ariaNgLogService.info('[CommandController] new download: ' + url); } else if (path.indexOf('/settings/rpc/set/') === 0) {