r47302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47301‎ | r47302 | r47303 >
Date:22:24, 15 February 2009
Author:aaron
Status:ok
Tags:
Comment:
Be clearer about large cidrs
Modified paths:
  • /trunk/extensions/CheckUser/checkuser.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/checkuser.js
@@ -57,7 +57,7 @@
5858 // Apply any valid CIDRs
5959 if( cidr ) {
6060 cidr = cidr.match( /\d+$/ )[0]; // get rid of slash
61 - if( cidr >= 16 ) bin = bin.substring(0,cidr); // truncate bin
 61+ bin = bin.substring(0,cidr); // truncate bin
6262 }
6363 // Init bin_prefix
6464 if( bin_prefix === 0 ) {
@@ -98,11 +98,11 @@
9999 // Convert the IP to binary form: IPv6
100100 } else if( ipV6 ) {
101101 var ip = ipV6[2];
102 - var cidr = ipV6[0].match( /\/\d+$/ );
 102+ var cidr = ipV6[0].match( /\/\d+$/ )[0];
103103 var abbrevs = ip.match( /::/g );
104 - if( abbrevs.length > 1 ) continue; // bad IP!
 104+ if( abbrevs && abbrevs.length > 1 ) continue; // bad IP!
105105 // Expand out "::"s
106 - if( abbrevs.length > 0 ) {
 106+ if( abbrevs && abbrevs.length > 0 ) {
107107 var colons = ip.match( /:/g );
108108 var needed = 7 - (colons.length - 2); // 2 from "::"
109109 var insert = '';
@@ -129,7 +129,7 @@
130130 // Apply any valid CIDRs
131131 if( cidr ) {
132132 cidr = cidr.match( /\d+$/ )[0]; // get rid of slash
133 - if( cidr >= 96 ) bin = bin.substring(0,cidr); // truncate bin
 133+ bin = bin.substring(0,cidr); // truncate bin
134134 }
135135 // Init bin_prefix
136136 if( bin_prefix === 0 ) {

Status & tagging log