luci-base: cbi.js: fix corner case in IPv6() address parser

The implementation allowed a hexadecimal string without any colons.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2018-10-19 08:21:51 +02:00
parent 7f613be500
commit 51fb04f6e0

View file

@ -106,7 +106,8 @@ function IPv6(x) {
var prefix = (prefix_suffix[0] || '0').split(/:/);
var suffix = prefix_suffix.length > 1 ? (prefix_suffix[1] || '0').split(/:/) : [];
if (suffix.length ? (prefix.length + suffix.length > 7) : (prefix.length > 8))
if (suffix.length ? (prefix.length + suffix.length > 7)
: ((prefix_suffix.length < 2 && prefix.length < 8) || prefix.length > 8))
return null;
var i, word;