diff options
author | Kyle Schwarz <zeranoe@gmail.com> | 2022-11-19 16:33:55 -0500 |
---|---|---|
committer | Kyle Schwarz <zeranoe@gmail.com> | 2022-11-19 16:34:04 -0500 |
commit | de9341648aba82ebbf4af1843854dffb9e63322e (patch) | |
tree | 09d4aa2bde52efaeb95e976186ade4895971ff6b /modules/luci-mod-network/htdocs/luci-static/resources/view | |
parent | 12487d4c11976e6ce20232e179d73c84a650b376 (diff) |
luci-mod-network: fix address validation
Fixes --server validation for:
- /domain[/domain]
- //
- /#/
Fixes hostname validation for:
- *.domain
- *domain
Changes ..domain to be an invalid hostname
Signed-off-by: Kyle Schwarz <zeranoe@gmail.com>
Diffstat (limited to 'modules/luci-mod-network/htdocs/luci-static/resources/view')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 2f61c8576b..1a308e2c61 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -126,7 +126,7 @@ function validateHostname(sid, s) { if (s.length > 256) return _('Expecting: %s').format(_('valid hostname')); - var labels = s.replace(/^\.+|\.$/g, '').split(/\./); + var labels = s.replace(/^\*?\.?|\.$/g, '').split(/\./); for (var i = 0; i < labels.length; i++) if (!labels[i].match(/^[a-z0-9_](?:[a-z0-9-]{0,61}[a-z0-9])?$/i)) @@ -156,13 +156,15 @@ function validateServerSpec(sid, s) { if (s == null || s == '') return true; - var m = s.match(/^(?:\/(.+)\/)?(.*)$/); + var m = s.match(/^(\/.*\/)?(.*)$/); if (!m) return _('Expecting: %s').format(_('valid hostname')); - var res = validateAddressList(sid, m[1]); - if (res !== true) - return res; + if (m[1] != '//' && m[1] != '/#/') { + var res = validateAddressList(sid, m[1]); + if (res !== true) + return res; + } if (m[2] == '' || m[2] == '#') return true; |