Skip to:
Content

BuddyPress.org

Ticket #7075: 7075.01.patch

File 7075.01.patch, 2.5 KB (added by r-a-y, 3 years ago)
  • src/bp-core/bp-core-catchuri.php

     
    555555         */
    556556        $me_slug = apply_filters( 'bp_core_members_shortlink_slug', 'me' );
    557557
     558        // Convert to utf-8 for localization.
     559        if ( true === function_exists( 'iconv_get_encoding' ) ) {
     560                $me_slug = iconv( iconv_get_encoding( 'internal_encoding' ), "UTF-8//TRANSLIT", $me_slug );
     561
     562        // This might not be accurate...
     563        } else {
     564                $me_slug = htmlentities( $me_slug, ENT_COMPAT | ENT_HTML401 );
     565        }
     566
     567        // Ensure our custom slug is URL-encoded.
     568        $me_slug = html_entity_decode( $me_slug, ENT_COMPAT | ENT_HTML401, 'utf-8' );
     569        $me_slug = rawurlencode( $me_slug );
     570
    558571        // Check if we're on our special shortlink slug. If not, bail.
    559572        if ( $me_slug !== $member_slug ) {
    560573                return $member_slug;
  • tests/phpunit/testcases/routing/members.php

     
    119119
    120120                $this->assertSame( get_current_user_id(), bp_displayed_user_id() );
    121121        }
     122
     123        /**
     124         * @ticket BP6325
     125         */
     126        function test_custom_member_slug_with_accents_in_shortlink_redirector() {
     127                // Emulate our custom slug as seen through bp_core_set_uri_globals().
     128                $custom_member_slug = 'regard%C3%A9';
     129
     130                add_filter( 'bp_core_members_shortlink_slug', array( $this, 'custom_member_slug_with_accents' ) );
     131
     132                $this->go_to( bp_get_members_directory_permalink() . $custom_member_slug );
     133
     134                remove_filter( 'bp_core_members_shortlink_slug', array( $this, 'custom_member_slug_with_accents' ) );
     135
     136                $this->assertSame( get_current_user_id(), bp_displayed_user_id() );
     137        }
     138
     139        /**
     140         * @ticket BP6325
     141         */
     142        function test_custom_member_slug_with_entity_in_shortlink_redirector() {
     143                // Emulate our custom slug as seen through bp_core_set_uri_globals().
     144                $custom_member_slug = 'regard%C3%A9';
     145
     146                add_filter( 'bp_core_members_shortlink_slug', array( $this, 'custom_member_slug_with_entities' ) );
     147
     148                $this->go_to( bp_get_members_directory_permalink() . $custom_member_slug );
     149
     150                remove_filter( 'bp_core_members_shortlink_slug', array( $this, 'custom_member_slug_with_entities' ) );
     151
     152                $this->assertSame( get_current_user_id(), bp_displayed_user_id() );
     153        }
     154
     155        function custom_member_slug_with_entities() {
     156                return 'regardé';
     157        }
     158
     159        function custom_member_slug_with_accents() {
     160                return 'regardé';
     161        }
    122162}