Parse request: Quote regular expression characters in home path.

Adds unit tests.

props akirk.
fixes #30438.
Built from https://develop.svn.wordpress.org/trunk@32708


git-svn-id: http://core.svn.wordpress.org/trunk@32678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-06-08 13:29:26 +00:00
parent 6d56231da3
commit 0549150843
2 changed files with 5 additions and 4 deletions

View File

@ -159,6 +159,7 @@ class WP {
list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
$self = $_SERVER['PHP_SELF'];
$home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' );
$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
// Trim path info from the end and the leading home path from the
// front. For path info requests, this leaves us with the requesting
@ -166,13 +167,13 @@ class WP {
// requested permalink.
$req_uri = str_replace($pathinfo, '', $req_uri);
$req_uri = trim($req_uri, '/');
$req_uri = preg_replace("|^$home_path|i", '', $req_uri);
$req_uri = preg_replace( $home_path_regex, '', $req_uri );
$req_uri = trim($req_uri, '/');
$pathinfo = trim($pathinfo, '/');
$pathinfo = preg_replace("|^$home_path|i", '', $pathinfo);
$pathinfo = preg_replace( $home_path_regex, '', $pathinfo );
$pathinfo = trim($pathinfo, '/');
$self = trim($self, '/');
$self = preg_replace("|^$home_path|i", '', $self);
$self = preg_replace( $home_path_regex, '', $self );
$self = trim($self, '/');
// The requested permalink is in $pathinfo for path info requests and

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32707';
$wp_version = '4.3-alpha-32708';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.