From: Daniel F. Dickinson Date: Sat, 5 Jan 2019 05:43:37 +0000 (-0500) Subject: luci-base: Fix addr:port validate always fails X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f5a871bfe89871dbdcf430ae8c81e46c15c1424a;p=oweals%2Fluci.git luci-base: Fix addr:port validate always fails In cbi.js there is an error which causes ipaddrport validation to always fail. JS match() return the entire match as ret[0] and individual matches (for multiple ()) as the subsequent list members. So we fix it by just fixing the index in the calls that want the individual parts. Signed-off-by: Daniel F. Dickinson --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index f93c9351a..67ddc6af3 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -443,10 +443,10 @@ var CBIValidatorPrototype = { m6 = this.value.match((bracket == 1) ? /^\[(.+)\]:(\d+)$/ : /^([^\[\]]+):(\d+)$/); if (m4) - return this.assert(this.apply('ip4addr', m4[0], [true]) && this.apply('port', m4[1]), + return this.assert(this.apply('ip4addr', m4[1], [true]) && this.apply('port', m4[2]), _('valid address:port')); - return this.assert(m6 && this.apply('ip6addr', m6[0], [true]) && this.apply('port', m6[1]), + return this.assert(m6 && this.apply('ip6addr', m6[1], [true]) && this.apply('port', m6[2]), _('valid address:port')); },