r21375 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21374‎ | r21375 | r21376 >
Date:13:33, 19 April 2007
Author:brion
Status:old
Tags:
Comment:
wfGetLastIPfromXFF() was clearly never tested either because it also DOESN'T FUCKING WORK
and HAS NO FUCKING DOCUMENTATION
and CAUSES ERRORS AND FAILURES
This quick hack should make it appear to basically work, assuming it does anything useful at all.
Modified paths:
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -25,6 +25,9 @@
2626 }
2727 }
2828
 29+/**
 30+ * @todo FUCKING DOCUMENT THIS FUCKING FUNCTION
 31+ */
2932 function wfGetLastIPfromXFF( $xff ) {
3033 if ( $xff ) {
3134 // Avoid annoyingly long xff hacks
@@ -34,12 +37,12 @@
3538 if ( strrpos !== false ) {
3639 $last = trim( substr( $xff, $n + 1 ) );
3740 // Make sure it is an IP
38 - $m = preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $last, $last_ip4);
39 - $n = preg_match('#:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}#', $last, $last_ip6);
 41+ $m = preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $last);
 42+ $n = preg_match('#^:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}$#', $last);
4043 if ( $m > 0 )
41 - $xff_ip = $last_ip4;
 44+ $xff_ip = $last;
4245 else if ( $n > 0 )
43 - $xff_ip = $last_ip6;
 46+ $xff_ip = $last;
4447 else
4548 $xff_ip = null;
4649 } else {