Changeset 46472
- Timestamp:
- 10/14/2019 10:50:41 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable.php
r46467 r46472 1419 1419 if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { 1420 1420 $path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' ); 1421 $path = wp_normalize_path( $path ); 1421 1422 } 1422 1423 $location = '/' . ltrim( $path . '/', '/' ) . $location; -
trunk/tests/phpunit/tests/formatting/redirect.php
r46462 r46472 142 142 ); 143 143 } 144 145 /** 146 * @ticket 47980 147 * @dataProvider relative_url_provider 148 */ 149 function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) { 150 // Backup the global. 151 $unset = false; 152 if ( ! isset( $_SERVER['REQUEST_URI'] ) ) { 153 $unset = true; 154 } else { 155 $backup_request_uri = $_SERVER['REQUEST_URI']; 156 } 157 158 // Set the global to current URI. 159 $_SERVER['REQUEST_URI'] = $current_uri; 160 161 $this->assertEquals( $expected, wp_validate_redirect( $url, false ) ); 162 163 // Delete or reset the global as required. 164 if ( $unset ) { 165 unset( $_SERVER['REQUEST_URI'] ); 166 } else { 167 $_SERVER['REQUEST_URI'] = $backup_request_uri; 168 } 169 } 170 171 /** 172 * Data provider for test_wp_validate_redirect_relative_url. 173 * 174 * @return array[] { 175 * string Current URI (i.e. path and query string only). 176 * string Redirect requested. 177 * string Expected destination. 178 * } 179 */ 180 function relative_url_provider() { 181 return array( 182 array( 183 '/', 184 'wp-login.php?loggedout=true', 185 '/wp-login.php?loggedout=true', 186 ), 187 array( 188 '/src/', 189 'wp-login.php?loggedout=true', 190 '/src/wp-login.php?loggedout=true', 191 ), 192 array( 193 '/wp-admin/settings.php?page=my-plugin', 194 './settings.php?page=my-plugin', 195 '/wp-admin/./settings.php?page=my-plugin', 196 ), 197 array( 198 '/wp-admin/settings.php?page=my-plugin', 199 '/wp-login.php', 200 '/wp-login.php', 201 ), 202 array( 203 '/wp-admin/settings.php?page=my-plugin', 204 '../wp-admin/admin.php?page=my-plugin', 205 '/wp-admin/../wp-admin/admin.php?page=my-plugin', 206 ), 207 array( 208 '/2019/10/13/my-post', 209 '../../', 210 '/2019/10/13/../../', 211 ), 212 array( 213 '/2019/10/13/my-post', 214 '/', 215 '/', 216 ), 217 ); 218 } 144 219 }
Note: See TracChangeset
for help on using the changeset viewer.