Skip to:
Content

bbPress.org

Changeset 5609


Ignore:
Timestamp:
01/30/2015 05:34:07 PM (10 years ago)
Author:
johnjamesjacoby
Message:

In bbp_current_author_ip() check $_SERVER['REMOTE_ADDR'] before attempting to parse it.

If it is empty (more likely for unit tests, but could be other oddities) we set it to '0.0.0.0' to do two things:

  • Indicate to keymasters that something is amiss
  • Allow bbp_current_author_ip() to proceed normally for the end-user

Fixes #2750.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/functions.php

    r5590 r5609  
    144144 */
    145145function bbp_current_author_ip() {
    146     $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
    147 
    148     return apply_filters( 'bbp_current_author_ip', $retval );
     146
     147    // Check for remote address
     148    $remote_address = ! empty( $_SERVER['REMOTE_ADDR'] )
     149        ? $_SERVER['REMOTE_ADDR']
     150        : '0.0.0.0';
     151
     152    // Remove any unsavory bits
     153    $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $remote_address );
     154
     155    return apply_filters( 'bbp_current_author_ip', $retval, $remote_address );
    149156}
    150157
Note: See TracChangeset for help on using the changeset viewer.