Make WordPress Core

Ticket #43745: 43745.diff

File 43745.diff, 1.4 KB (added by soulseekah, 6 years ago)

fix + tests

  • src/wp-includes/canonical.php

    diff --git src/wp-includes/canonical.php src/wp-includes/canonical.php
    index ad219c2..c83d839 100644
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    388388                        }
    389389                }
    390390
    391                 $_parsed_query = rawurlencode_deep( $_parsed_query );
     391                $_parsed_query = array_combine(
     392                        rawurlencode_deep( array_keys( $_parsed_query ) ),
     393                        rawurlencode_deep( array_values( $_parsed_query ) )
     394                );
    392395                $redirect_url  = add_query_arg( $_parsed_query, $redirect_url );
    393396        }
    394397
  • tests/phpunit/tests/canonical.php

    diff --git tests/phpunit/tests/canonical.php tests/phpunit/tests/canonical.php
    index a2bbc06..6a737f4 100644
    class Tests_Canonical extends WP_Canonical_UnitTestCase { 
    213213                        // Todo: Endpoints (feeds, trackbacks, etc), More fuzzed mixed query variables, comment paging, Home page (Static)
    214214                );
    215215        }
     216
     217        /**
     218         * @ticket 43745
     219         */
     220        public function test_utf8_query_keys_canonical() {
     221                $p = self::factory()->post->create(
     222                        array(
     223                                'post_type'  => 'page',
     224                        )
     225                );
     226                update_option( 'show_on_front', 'page' );
     227                update_option( 'page_on_front', $p );
     228
     229                $this->go_to( get_permalink( $p ) );
     230
     231                $url = redirect_canonical( add_query_arg( '%D0%BA%D0%BE%D0%BA%D0%BE%D0%BA%D0%BE', 1, site_url( '/' ) ), false );
     232                $this->assertNull( $url );
     233
     234                delete_option( 'page_on_front' );
     235        }
    216236}