fix(ui): reject DoH URLs and path-style DoH in dns_fallback_server field

Mirror the backend validator.uc checks in the LuCI settings UI.
Previously the validate function used validateDNS() which accepts
DoH path format (e.g. 'cloudflare-dns.com/dns-query'); now we gate
before that call with explicit checks matching the backend:
  - '://' → DoH/DoT URL (e.g. 'https://cloudflare-dns.com/...')
  - '/'   → path-style DoH (e.g. 'cloudflare-dns.com/dns-query')

Also add Russian translations for both new error messages.
This commit is contained in:
Dushnilin
2026-09-02 14:20:33 +03:00
parent 6b8e143d0b
commit 557058c772
2 changed files with 13 additions and 0 deletions
@@ -1409,6 +1409,13 @@ function createSettingsContent(section, capabilities) {
fallbackDnsOption.validate = function (_section_id, value) {
const normalized = `${value || ""}`.trim();
if (!normalized) return true; // allow empty list
// Fallback servers are plain-UDP only — reject DoH/DoT/DoQ URLs and
// path-style DoH (e.g. "cloudflare-dns.com/dns-query"). This mirrors
// the backend validator.uc check so the user gets immediate feedback.
if (normalized.includes("://"))
return _("Fallback DNS servers must be plain UDP (IP or hostname). DoH/DoT URLs are not allowed here.");
if (normalized.includes("/"))
return _("Fallback DNS servers must be plain UDP (IP or hostname). Path-style DoH (e.g. domain/path) is not allowed here.");
const validation = main.validateDNS(normalized);
return validation.valid ? true : validation.message;
};