Skip to content

Add validation for custom DoH server inputs#28

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-doh-url-check
Draft

Add validation for custom DoH server inputs#28
Copilot wants to merge 3 commits intomainfrom
copilot/fix-doh-url-check

Conversation

Copy link

Copilot AI commented Jan 27, 2026

Custom DoH servers could be added without validation, allowing malformed URLs, HTTP URLs, and empty names to reach the capability check.

Changes

  • Name validation: Reject empty names after trimming whitespace
  • URL format validation: Use URL constructor to catch malformed inputs
  • Protocol validation: Enforce HTTPS requirement for DoH
  • Input normalization: Trim whitespace, handle commas in URLs via slice(1).join(', ')
// Validate URL format and protocol
let parsedUrl;
try {
    parsedUrl = new URL(url);
} catch (_) {
    alert("Invalid URL format. Please enter a valid URL (e.g., https://example.com/dns-query).");
    return;
}

if (parsedUrl.protocol !== 'https:') {
    alert("DoH URLs must use HTTPS protocol. Please enter a URL starting with 'https://'.");
    return;
}

Validation errors now surface with clear messages before attempting capability checks on invalid endpoints.

DoH Modal

Original prompt

This section details on the original issue you should resolve

<issue_title>Without check for doh url</issue_title>
<issue_description>I use my own doh url, like "https://xxx.net/xxx-query".such as "https://xxx.net/us-query","https://xxx.net/jp-query"</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: s1lviu <9863576+s1lviu@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 27, 2026

Deploying dohspeedtest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40b7f2f
Status: ✅  Deploy successful!
Preview URL: https://4e38106e.dohspeedtest.pages.dev
Branch Preview URL: https://copilot-fix-doh-url-check.dohspeedtest.pages.dev

View logs

Co-authored-by: s1lviu <9863576+s1lviu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing check for custom DOH URL Add validation for custom DoH server inputs Jan 27, 2026
Copilot AI requested a review from s1lviu January 27, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Without check for doh url

2 participants