libs/web: fix IPv6 live validation
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 23 Nov 2010 23:19:40 +0000 (23:19 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 23 Nov 2010 23:19:40 +0000 (23:19 +0000)
libs/web/htdocs/luci-static/resources/cbi.js

index 059d27a1b921ae92bc7ff907ef35f4a19fb671de..62dada464e276acfc41b87cb27ac544f010e7b49 100644 (file)
@@ -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);