Index: trunk/extensions/CheckUser/checkuser.js |
— | — | @@ -40,7 +40,6 @@ |
41 | 41 | // Go through each IP in the list, get its binary form, and |
42 | 42 | // track the largest binary prefix among them... |
43 | 43 | for( var i = 0; i < ips.length; i++ ) { |
44 | | - var invalid = false; |
45 | 44 | // ...in the spirit of block.js, call this "addy" |
46 | 45 | var addy = ips[i].replace(/^\s*|\s*$/, '' ); // trim |
47 | 46 | // Match the first IP in each list (ignore other garbage) |
— | — | @@ -61,24 +60,15 @@ |
62 | 61 | // Get each quad integer |
63 | 62 | var blocs = ip.split('.'); |
64 | 63 | // 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; |
68 | 65 | for( var x = 0; x < blocs.length; x++ ) { |
69 | 66 | bloc = parseInt( blocs[x], 10 ); |
70 | | - if( bloc > 255 ) { |
71 | | - invalid = true; // bad IP! |
72 | | - break; // bad IP! |
73 | | - } |
74 | 67 | bin_block = bloc.toString( 2 ); // concat bin with binary form of bloc |
75 | 68 | while( bin_block.length < 8 ) { |
76 | 69 | bin_block = '0' + bin_block; // pad out as needed |
77 | 70 | } |
78 | 71 | bin += bin_block; |
79 | 72 | } |
80 | | - if( invalid ) { |
81 | | - continue; // move to next IP |
82 | | - } |
83 | 73 | prefix = ''; // Rebuild formatted bin_prefix for each IP |
84 | 74 | // Apply any valid CIDRs |
85 | 75 | if( cidr ) { |
— | — | @@ -102,7 +92,8 @@ |
103 | 93 | // CIDR too small? |
104 | 94 | if( prefix_cidr < 16 ) { |
105 | 95 | document.getElementById( 'mw-checkuser-cidr-res' ).value = '!'; |
106 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' + Math.pow( 2, 32 - prefix_cidr ); |
| 96 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' + |
| 97 | + Math.pow( 2, 32 - prefix_cidr ); |
107 | 98 | return; // too big |
108 | 99 | } |
109 | 100 | // Build the IP in dotted-quad form |
— | — | @@ -154,10 +145,6 @@ |
155 | 146 | var blocs = ip.split(':'); |
156 | 147 | for( var x = 0; x <= 7; x++ ) { |
157 | 148 | bloc = blocs[x] ? blocs[x] : '0'; |
158 | | - if( bloc > 'ffff' ) { |
159 | | - invalid = true; // bad IP! |
160 | | - break; // bad IP! |
161 | | - } |
162 | 149 | int_block = hex2int( bloc ); // convert hex -> int |
163 | 150 | bin_block = int_block.toString( 2 ); // concat bin with binary form of bloc |
164 | 151 | while( bin_block.length < 16 ) { |
— | — | @@ -165,9 +152,6 @@ |
166 | 153 | } |
167 | 154 | bin += bin_block; |
168 | 155 | } |
169 | | - if( invalid ) { |
170 | | - continue; // move to next IP |
171 | | - } |
172 | 156 | prefix = ''; // Rebuild formatted bin_prefix for each IP |
173 | 157 | // Apply any valid CIDRs |
174 | 158 | if( cidr ) { |
— | — | @@ -191,7 +175,8 @@ |
192 | 176 | // CIDR too small? |
193 | 177 | if( prefix_cidr < 96 ) { |
194 | 178 | document.getElementById( 'mw-checkuser-cidr-res' ).value = '!'; |
195 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' + Math.pow( 2, 128 - prefix_cidr ); |
| 179 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' |
| 180 | + + Math.pow( 2, 128 - prefix_cidr ); |
196 | 181 | return; // too big |
197 | 182 | } |
198 | 183 | // Build the IP in dotted-quad form |