r78162 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78161‎ | r78162 | r78163 >
Date:00:26, 10 December 2010
Author:aaron
Status:ok
Tags:
Comment:
* Remove some unecessary JS code (given r78161)
* Broke long lines
Modified paths:
  • /trunk/extensions/CheckUser/checkuser.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/checkuser.js
@@ -40,7 +40,6 @@
4141 // Go through each IP in the list, get its binary form, and
4242 // track the largest binary prefix among them...
4343 for( var i = 0; i < ips.length; i++ ) {
44 - var invalid = false;
4544 // ...in the spirit of block.js, call this "addy"
4645 var addy = ips[i].replace(/^\s*|\s*$/, '' ); // trim
4746 // Match the first IP in each list (ignore other garbage)
@@ -61,24 +60,15 @@
6261 // Get each quad integer
6362 var blocs = ip.split('.');
6463 // IANA 1.0.0.0/8, 2.0.0.0/8
65 - if( blocs[0] < 3 ) {
66 - continue;
67 - }
 64+ if( blocs[0] <= 2 ) continue;
6865 for( var x = 0; x < blocs.length; x++ ) {
6966 bloc = parseInt( blocs[x], 10 );
70 - if( bloc > 255 ) {
71 - invalid = true; // bad IP!
72 - break; // bad IP!
73 - }
7467 bin_block = bloc.toString( 2 ); // concat bin with binary form of bloc
7568 while( bin_block.length < 8 ) {
7669 bin_block = '0' + bin_block; // pad out as needed
7770 }
7871 bin += bin_block;
7972 }
80 - if( invalid ) {
81 - continue; // move to next IP
82 - }
8373 prefix = ''; // Rebuild formatted bin_prefix for each IP
8474 // Apply any valid CIDRs
8575 if( cidr ) {
@@ -102,7 +92,8 @@
10393 // CIDR too small?
10494 if( prefix_cidr < 16 ) {
10595 document.getElementById( 'mw-checkuser-cidr-res' ).value = '!';
106 - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;' + Math.pow( 2, 32 - prefix_cidr );
 96+ document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;' +
 97+ Math.pow( 2, 32 - prefix_cidr );
10798 return; // too big
10899 }
109100 // Build the IP in dotted-quad form
@@ -154,10 +145,6 @@
155146 var blocs = ip.split(':');
156147 for( var x = 0; x <= 7; x++ ) {
157148 bloc = blocs[x] ? blocs[x] : '0';
158 - if( bloc > 'ffff' ) {
159 - invalid = true; // bad IP!
160 - break; // bad IP!
161 - }
162149 int_block = hex2int( bloc ); // convert hex -> int
163150 bin_block = int_block.toString( 2 ); // concat bin with binary form of bloc
164151 while( bin_block.length < 16 ) {
@@ -165,9 +152,6 @@
166153 }
167154 bin += bin_block;
168155 }
169 - if( invalid ) {
170 - continue; // move to next IP
171 - }
172156 prefix = ''; // Rebuild formatted bin_prefix for each IP
173157 // Apply any valid CIDRs
174158 if( cidr ) {
@@ -191,7 +175,8 @@
192176 // CIDR too small?
193177 if( prefix_cidr < 96 ) {
194178 document.getElementById( 'mw-checkuser-cidr-res' ).value = '!';
195 - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;' + Math.pow( 2, 128 - prefix_cidr );
 179+ document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;'
 180+ + Math.pow( 2, 128 - prefix_cidr );
196181 return; // too big
197182 }
198183 // Build the IP in dotted-quad form

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78161*Follow-up r78099,r76275:...aaron00:16, 10 December 2010

Status & tagging log