Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/16/2014 12:03:53 PM (11 years ago)
Author:
imath
Message:

Make sure BP_User_Query returns correct results when search term contains the Ampersand character

  1. Search terms containing this character was problematic as the "&" is a query var delimiter used in bp_legacy_theme_ajax_querystring() to build the ajax querystring
  1. When a xProfile field is saved, the value is sanitized using the xprofile_filter_kses() filter which is converting "&" to "&" before inserting the value in database.

Urlencoding the search terms in bp_legacy_theme_ajax_querystring() and applying wp_kses_normalize_entities() to search terms in BP_User_Query & in bp_xprofile_bp_user_query_search() make sure the correct results are returned to the user.

Fixes #5694

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r8675 r8928  
    202202    }
    203203
     204    public function test_bp_user_query_search_with_ampersand_sign() {
     205
     206        // LIKE special character: &
     207        $user_id = $this->create_user();
     208        xprofile_set_field_data( 1, $user_id, "a&mpersand" );
     209        $q = new BP_User_Query( array( 'search_terms' => "a&m", ) );
     210
     211        $found_user_id = null;
     212        if ( ! empty( $q->results ) ) {
     213            $found_user = array_pop( $q->results );
     214            $found_user_id = $found_user->ID;
     215        }
     216
     217        $this->assertEquals( $user_id, $found_user_id );
     218
     219    }
     220
    204221    /**
    205222     * @group search_terms
Note: See TracChangeset for help on using the changeset viewer.