From: Jo-Philipp Wich Date: Tue, 23 Nov 2010 23:19:40 +0000 (+0000) Subject: libs/web: fix IPv6 live validation X-Git-Tag: 0.10.0~379 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6d02d50d461356343b742a2914b85e2d6d0ba5e1;p=oweals%2Fluci.git libs/web: fix IPv6 live validation --- diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 059d27a1b..62dada464 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -75,7 +75,7 @@ var cbi_validators = { var colons = 0; var fill = '0'; - for( var i = 0; i < addr.length; i++ ) + for( var i = 1; i < (addr.length-1); i++ ) if( addr.charAt(i) == ':' ) colons++; @@ -85,7 +85,9 @@ var cbi_validators = { for( var i = 0; i < (7 - colons); i++ ) fill += ':0'; - addr = addr.replace(/::/, ':' + fill + ':'); + if (addr.match(/^(.*?)::(.*?)$/)) + addr = (RegExp.$1 ? RegExp.$1 + ':' : '') + fill + + (RegExp.$2 ? ':' + RegExp.$2 : ''); } return (addr.match(/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/) != null);