From f33f3eeb58db2cddc95b69214160f02f9157537c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 3 Oct 2021 03:37:04 +0300 Subject: more input validation --- assets/js/main.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'assets') diff --git a/assets/js/main.js b/assets/js/main.js index 51ace3b..79e0dd2 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -10,6 +10,9 @@ function parse_endpoint(val) { if (val.length == 0) { throw new Error('Server endpoint cannot be an empty string.'); } + if (!val.match(/^.+:[0-9]+$/)) { + throw new Error('Please specify a host and a port in the HOST:PORT format.'); + } return val; } @@ -18,6 +21,9 @@ function parse_key(val) { if (val.length == 0) { throw new Error('Key as used by WireGuard cannot be an empty string.'); } + if (!val.match(/^[0-9a-zA-Z+/=]+$/)) { + throw new Error('Key as used by WireGuard must be Base64-encoded.'); + } return val; } -- cgit v1.2.3