From c67d312dd1e588e0d5cb588d7a6ba3f5e2f02d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kol=C3=A1rik?= Date: Sat, 8 Feb 2025 15:18:47 +0100 Subject: [PATCH] Add hostname validation to URL parsing --- src/views/components/tags-input.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/views/components/tags-input.html b/src/views/components/tags-input.html index 07a2cfa26..168dc1d77 100644 --- a/src/views/components/tags-input.html +++ b/src/views/components/tags-input.html @@ -381,6 +381,11 @@ try { let { protocol, port, pathname, hostname, search } = new URL(url); + if (!hostname) { + // Just one extra check. The constructor above may throw too. + throw new Error('Invalid URL'); + } + this.set('gpMainOpts.type', 'HTTP'); this.set('gpMainOpts.target', tagsArr ? [ ...tagsArr, hostname ].join(delimiter) : hostname); this.set('gpHttpOpts.protocol', protocol.replace(':', '').toUpperCase());