luci-base: Fix addr:port validate always fails 2425/head
authorDaniel F. Dickinson <cshored@thecshore.com>
Sat, 5 Jan 2019 05:43:37 +0000 (00:43 -0500)
committerDaniel F. Dickinson <cshored@thecshore.com>
Sat, 5 Jan 2019 05:43:37 +0000 (00:43 -0500)
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 <cshored@thecshore.com>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index f93c9351a784d30799074172acf842d1ba287e12..67ddc6af365703a3937566bd925ee5599809cf27 100644 (file)
@@ -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'));
                },