From ff981532fd8439b74dcaf5da57693937df9990c4 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 2 Nov 2018 08:39:09 -0400 Subject: [PATCH] whitelist of protocols for can launch --- src/models/view/loginUriView.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/models/view/loginUriView.ts b/src/models/view/loginUriView.ts index c402c6fb3b..ae9f509053 100644 --- a/src/models/view/loginUriView.ts +++ b/src/models/view/loginUriView.ts @@ -6,6 +6,16 @@ import { LoginUri } from '../domain/loginUri'; import { Utils } from '../../misc/utils'; +const CanLaunchWhitelist = [ + 'https://', + 'http://', + 'ssh://', + 'ftp://', + 'sftp://', + 'irc://', + 'chrome://', +]; + export class LoginUriView implements View { match: UriMatchType = null; @@ -62,6 +72,14 @@ export class LoginUriView implements View { } get canLaunch(): boolean { - return this.uri != null && this.uri.indexOf('://') > -1; + if (this.uri == null) { + return false; + } + for (let i = 0; i < CanLaunchWhitelist.length; i++) { + if (this.uri.indexOf(CanLaunchWhitelist[i]) === 0) { + return true; + } + } + return false; } }