WordPress.org

Make WordPress Core

Ticket #35355: 35355.2.diff

File 35355.2.diff, 1.6 KB (added by westonruter, 5 years ago)
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 66fb7ff..4f4fcf1 100644
    final class WP_Customize_Manager { 
    15791579         */
    15801580        public function get_return_url() {
    15811581                $referer = wp_get_referer();
     1582                $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' );
     1583
    15821584                if ( $this->return_url ) {
    15831585                        $return_url = $this->return_url;
    1584                 } else if ( $referer && 'customize.php' !== basename( parse_url( $referer, PHP_URL_PATH ) ) ) {
     1586                } else if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
    15851587                        $return_url = $referer;
    15861588                } else if ( $this->preview_url ) {
    15871589                        $return_url = $this->preview_url;
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index 929df0a..e787cfa 100644
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    322322                $_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'customize.php' ) );
    323323                $this->assertEquals( $preview_url, $this->manager->get_return_url() );
    324324
     325                // See #35355.
     326                $_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'wp-login.php' ) );
     327                $this->assertEquals( $preview_url, $this->manager->get_return_url() );
     328
    325329                $url = home_url( '/referred/' );
    326330                $_SERVER['HTTP_REFERER'] = wp_slash( $url );
    327331                $this->assertEquals( $url, $this->manager->get_return_url() );