From 0549150843e85805f7b48562af2398271e28c1ab Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 8 Jun 2015 13:29:26 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp.php | 7 ++++--- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 8a2f177a04..b5d9f91c24 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -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 diff --git a/wp-includes/version.php b/wp-includes/version.php index 37700bce5f..292e6238c5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.