WordPress.org

Make WordPress Core

Ticket #36827: 36827.patch

File 36827.patch, 1.5 KB (added by curdin, 5 years ago)

Patch and unit tests ( with .patch extension - thanks @netweb )

  • src/wp-includes/functions.php

     
    41544154
    41554155                // The request is for the admin
    41564156                if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
    4157                         $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
     4157                        $path = preg_replace( '#/(wp-admin/?.*|wp-login\.php.*)#i', '', $_SERVER['REQUEST_URI'] );
    41584158
    41594159                // The request is for a file in ABSPATH
    41604160                } elseif ( $script_filename_dir . '/' == $abspath_fix ) {
  • tests/phpunit/tests/includes/helpers.php

     
    212212        public function test_die_handler_should_handle_wp_error() {
    213213                wp_die( new WP_Error( 'test', 'test' ) );
    214214        }
     215
     216
     217        function data_guessUrlTestCases() {
     218                return array(
     219                        ['wp-admin'],
     220                        ['wp-admin/'],
     221                        ['wp-admin/?foo=bar'],
     222                        ['wp-login.php'],
     223                        ['wp-login.php?foo=bar']
     224                );
     225        }
     226
     227        /**
     228         * @dataProvider data_guessUrlTestCases
     229         * @ticket 36827
     230         */
     231        public function test_guessUrlShouldHandleEdgecases( $url ) {
     232                $siteurl = site_url();
     233                $this->go_to( site_url( $url ) );
     234                $this->assertEquals($siteurl, wp_guess_url());
     235        }
     236
    215237}