From a7abf81bb30d893573bef78e432f777ad7290b03 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 06:57:12 +0000 Subject: [PATCH 1/3] Initial plan From 58c490a6eb630bf6ae60b7d73c46fee1d5f97940 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 07:00:21 +0000 Subject: [PATCH 2/3] Add DoH URL validation for custom server inputs Co-authored-by: s1lviu <9863576+s1lviu@users.noreply.github.com> --- script.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 8f7bc8c..6ec4b49 100644 --- a/script.js +++ b/script.js @@ -931,7 +931,29 @@ document.addEventListener('DOMContentLoaded', function () { addDoHBtn.onclick = function () { const serverDetails = newDoHInput.value.split(', '); // Expected format: "Name, URL" if (serverDetails.length >= 2) { - const [name, url] = serverDetails; + const name = serverDetails[0].trim(); + const url = serverDetails.slice(1).join(', ').trim(); // Handle URLs with commas + + // Validate the name + if (!name) { + alert("Server name cannot be empty."); + return; + } + + // Validate the URL format and protocol + let parsedUrl; + try { + parsedUrl = new URL(url); + } catch (e) { + alert("Invalid URL format. Please enter a valid URL (e.g., https://example.com/dns-query)."); + return; + } + + // Check if URL uses HTTPS protocol (required for DoH) + if (parsedUrl.protocol !== 'https:') { + alert("DoH URLs must use HTTPS protocol. Please enter a URL starting with 'https://'."); + return; + } // Check if server already exists by URL or name const isDuplicate = dnsServers.some(server => server.url === url || server.name === name); From 40b7f2fc2e9c42e4f6d6c32adf2fa273639c4de3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 07:00:55 +0000 Subject: [PATCH 3/3] Use underscore for unused exception parameter Co-authored-by: s1lviu <9863576+s1lviu@users.noreply.github.com> --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 6ec4b49..c9d22dd 100644 --- a/script.js +++ b/script.js @@ -944,7 +944,7 @@ document.addEventListener('DOMContentLoaded', function () { let parsedUrl; try { parsedUrl = new URL(url); - } catch (e) { + } catch (_) { alert("Invalid URL format. Please enter a valid URL (e.g., https://example.com/dns-query)."); return; }