Ticket #30438: 30438.2.diff
File 30438.2.diff, 2.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/class-wp.php
157 157 list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); 158 158 $self = $_SERVER['PHP_SELF']; 159 159 $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); 160 $home_path_escaped = preg_quote( $home_path, '|' ); 160 161 161 162 // Trim path info from the end and the leading home path from the 162 163 // front. For path info requests, this leaves us with the requesting … … 164 165 // requested permalink. 165 166 $req_uri = str_replace($pathinfo, '', $req_uri); 166 167 $req_uri = trim($req_uri, '/'); 167 $req_uri = preg_replace( "|^$home_path|i", '', $req_uri);168 $req_uri = preg_replace( "|^$home_path_escaped|i", '', $req_uri ); 168 169 $req_uri = trim($req_uri, '/'); 169 170 $pathinfo = trim($pathinfo, '/'); 170 $pathinfo = preg_replace( "|^$home_path|i", '', $pathinfo);171 $pathinfo = preg_replace( "|^$home_path_escaped|i", '', $pathinfo ); 171 172 $pathinfo = trim($pathinfo, '/'); 172 173 $self = trim($self, '/'); 173 $self = preg_replace( "|^$home_path|i", '', $self);174 $self = preg_replace( "|^$home_path_escaped|i", '', $self ); 174 175 $self = trim($self, '/'); 175 176 176 177 // The requested permalink is in $pathinfo for path info requests and -
tests/phpunit/tests/rewrite.php
6 6 * @group rewrite 7 7 */ 8 8 class Tests_Rewrite extends WP_UnitTestCase { 9 private $home_url; 9 10 10 11 function setUp() { 11 12 global $wp_rewrite; … … 18 19 create_initial_taxonomies(); 19 20 20 21 $wp_rewrite->flush_rules(); 22 23 $this->home_url = get_option( 'home' ); 21 24 } 22 25 23 26 function tearDown() { … … 24 27 global $wp_rewrite; 25 28 $wp_rewrite->init(); 26 29 30 update_option( 'home', $this->home_url ); 27 31 parent::tearDown(); 28 32 } 29 33 … … 74 78 $this->assertEquals( 0, url_to_postid( '/example-page/ex/' ) ); 75 79 } 76 80 81 function test_parse_request_home_path() { 82 $home_url = home_url( '/path/' ); 83 update_option( 'home', $home_url ); 84 85 $this->go_to( $home_url ); 86 $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); 87 88 $this->go_to( $home_url . 'page'); 89 $this->assertEquals( array('page' => '', 'pagename' => 'page'), $GLOBALS['wp']->query_vars ); 90 } 91 92 function test_parse_request_home_path_with_regexchar() { 93 $home_url = home_url( '/pa+th/' ); 94 update_option( 'home', $home_url ); 95 96 $this->go_to( $home_url ); 97 $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); 98 99 $this->go_to( $home_url . 'page'); 100 $this->assertEquals( array('page' => '', 'pagename' => 'page'), $GLOBALS['wp']->query_vars ); 101 } 102 77 103 function test_url_to_postid_dupe_path() { 78 104 update_option( 'home', home_url('/example/') ); 79 105