luci-base: cbi.js: fix corner case in IPv6() address parser
authorJo-Philipp Wich <jo@mein.io>
Fri, 19 Oct 2018 06:21:51 +0000 (08:21 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 5 Nov 2018 10:01:45 +0000 (11:01 +0100)
The implementation allowed a hexadecimal string without any colons.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index b92b86f52333c6341a772efe57b5adfb775ccd97..6243e5edbf997a389be5014bfee2940f892cbe83 100644 (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;