mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Parse request: Quote regular expression characters in home path.
Adds unit tests. props akirk. fixes #30438. git-svn-id: https://develop.svn.wordpress.org/trunk@32708 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user