wfGetLastIPfromXFF() was clearly never tested either because it also DOESN'T FUCKING...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Apr 2007 13:33:13 +0000 (13:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 19 Apr 2007 13:33:13 +0000 (13:33 +0000)
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.

includes/ProxyTools.php

index fcd6a90..e72a338 100644 (file)
@@ -25,6 +25,9 @@ function wfGetForwardedFor() {
        }
 }
 
+/**
+ * @todo FUCKING DOCUMENT THIS FUCKING FUNCTION
+ */
 function wfGetLastIPfromXFF( $xff ) {
        if ( $xff ) {
        // Avoid annoyingly long xff hacks
@@ -34,12 +37,12 @@ function wfGetLastIPfromXFF( $xff ) {
                if ( strrpos !== false ) {
                        $last = trim( substr( $xff, $n + 1 ) );
                        // Make sure it is an IP
-                       $m = preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $last, $last_ip4);
-                       $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);
+                       $m = preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $last);
+                       $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);
                        if ( $m > 0 )
-                               $xff_ip = $last_ip4;
+                               $xff_ip = $last;
                        else if ( $n > 0 ) 
-                               $xff_ip = $last_ip6;
+                               $xff_ip = $last;
                        else 
                                $xff_ip = null;
                } else {