Minor bugfix to IP::prettifyIP.
authorC. Scott Ananian <cscott@cscott.net>
Thu, 12 Sep 2013 15:17:42 +0000 (08:17 -0700)
committerC. Scott Ananian <cscott@cscott.net>
Thu, 12 Sep 2013 15:17:42 +0000 (08:17 -0700)
The offset returned by preg_match with the PREG_OFFSET_CAPTURE is an
absolute position in the string.  You shouldn't *add* it to the
current position in order to advance past the match.

Change-Id: I3631c34e02d9b830bf841bf960855626fbc88eb0

includes/IP.php

index 2051e69..fc76310 100644 (file)
@@ -212,7 +212,7 @@ class IP {
                                        $longest = $match;
                                        $longestPos = $pos;
                                }
-                               $offset += ( $pos + strlen( $match ) ); // advance
+                               $offset = ( $pos + strlen( $match ) ); // advance
                        }
                        if ( $longest !== false ) {
                                // Replace this portion of the string with the '::' abbreviation