http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76275

Revision: 76275
Author:   aaron
Date:     2010-11-07 22:46:22 +0000 (Sun, 07 Nov 2010)
Log Message:
-----------
Similar to r76267 but for JS. Should finish bug 24293.

Modified Paths:
--------------
    trunk/extensions/CheckUser/checkuser.js
    trunk/phase3/skins/common/block.js

Modified: trunk/extensions/CheckUser/checkuser.js
===================================================================
--- trunk/extensions/CheckUser/checkuser.js     2010-11-07 22:45:20 UTC (rev 
76274)
+++ trunk/extensions/CheckUser/checkuser.js     2010-11-07 22:46:22 UTC (rev 
76275)
@@ -41,9 +41,12 @@
                var invalid = false;
                // ...in the spirit of block.js, call this "addy"
                var addy = ips[i];
+               // @TODO: get some core JS IP functions
                // Match the first IP in each list (ignore other garbage)
                var ipV4 = addy.match(/(^|\b)(\d+\.\d+\.\d+\.\d+)(\/\d+)?\b/);
-               var ipV6 = 
addy.match(/(^|\b)(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?\b/);
+               // Regexp has 3 cases: (starts with '::',ends with '::',neither)
+               var ipV6 = !addy.match(/::.*::/) // not ambiguous
+                       && 
addy.match(/(^|\b)(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){0,6}::|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){1,7})(\/\d+)?\b/);
                // Binary form
                var bin = new String( '' );
                // Convert the IP to binary form: IPv4

Modified: trunk/phase3/skins/common/block.js
===================================================================
--- trunk/phase3/skins/common/block.js  2010-11-07 22:45:20 UTC (rev 76274)
+++ trunk/phase3/skins/common/block.js  2010-11-07 22:46:22 UTC (rev 76275)
@@ -29,7 +29,15 @@
 
        var addy = target.value;
        var isEmpty = addy.match(/^\s*$/);
-       var isIp = 
addy.match(/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?$/);
+
+       // @TODO: get some core JS IP functions
+       // Match the first IP in each list (ignore other garbage)
+       var isIpV4 = addy.match(/^(\d+\.\d+\.\d+\.\d+)(\/\d+)?$/);
+       // Regexp has 3 cases: (starts with '::',ends with '::',neither)
+       var isIpV6 = !addy.match(/::.*::/) // not ambiguous
+               && 
addy.match(/^(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){0,6}::|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){1,7})(\/\d+)?$/);
+
+       var isIp = ( isIpV4 || isIpV6 );
        var isIpRange = isIp && addy.match(/\/\d+$/);
 
        var anonymousRow = document.getElementById( 'wpAnonOnlyRow' );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to