Index: trunk/phase3/skins/common/block.js |
— | — | @@ -29,7 +29,15 @@ |
30 | 30 | |
31 | 31 | var addy = target.value; |
32 | 32 | var isEmpty = addy.match(/^\s*$/); |
33 | | - 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+)?$/); |
| 33 | + |
| 34 | + // @TODO: get some core JS IP functions |
| 35 | + // Match the first IP in each list (ignore other garbage) |
| 36 | + var isIpV4 = addy.match(/^(\d+\.\d+\.\d+\.\d+)(\/\d+)?$/); |
| 37 | + // Regexp has 3 cases: (starts with '::',ends with '::',neither) |
| 38 | + var isIpV6 = !addy.match(/::.*::/) // not ambiguous |
| 39 | + && 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+)?$/); |
| 40 | + |
| 41 | + var isIp = ( isIpV4 || isIpV6 ); |
34 | 42 | var isIpRange = isIp && addy.match(/\/\d+$/); |
35 | 43 | |
36 | 44 | var anonymousRow = document.getElementById( 'wpAnonOnlyRow' ); |
Index: trunk/extensions/CheckUser/checkuser.js |
— | — | @@ -41,9 +41,12 @@ |
42 | 42 | var invalid = false; |
43 | 43 | // ...in the spirit of block.js, call this "addy" |
44 | 44 | var addy = ips[i]; |
| 45 | + // @TODO: get some core JS IP functions |
45 | 46 | // Match the first IP in each list (ignore other garbage) |
46 | 47 | var ipV4 = addy.match(/(^|\b)(\d+\.\d+\.\d+\.\d+)(\/\d+)?\b/); |
47 | | - 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/); |
| 48 | + // Regexp has 3 cases: (starts with '::',ends with '::',neither) |
| 49 | + var ipV6 = !addy.match(/::.*::/) // not ambiguous |
| 50 | + && 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/); |
48 | 51 | // Binary form |
49 | 52 | var bin = new String( '' ); |
50 | 53 | // Convert the IP to binary form: IPv4 |