From 6d02d50d461356343b742a2914b85e2d6d0ba5e1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 23 Nov 2010 23:19:40 +0000 Subject: libs/web: fix IPv6 live validation --- libs/web/htdocs/luci-static/resources/cbi.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libs/web') 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); -- cgit v1.2.3