From 424dd330fe2f3ab68bf5e698aaa8949b3f58dc32 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 28 Dec 2005 01:48:29 +0000 Subject: [PATCH] Anchor str replacements to head so that we don't replace across the entire string. fixes #2162 git-svn-id: https://develop.svn.wordpress.org/trunk@3370 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/classes.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 3cf1dffbc2..ac805a1fd6 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -1461,16 +1461,21 @@ class WP { $self = $_SERVER['PHP_SELF']; $home_path = parse_url(get_settings('home')); $home_path = $home_path['path']; + $home_path = trim($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 // filename, if any. For 404 requests, this leaves us with the // requested permalink. $req_uri = str_replace($pathinfo, '', $req_uri); - $req_uri = str_replace($home_path, '', $req_uri); $req_uri = trim($req_uri, '/'); - $pathinfo = str_replace($home_path, '', $pathinfo); + $req_uri = preg_replace("|^$home_path|", '', $req_uri); + $req_uri = trim($req_uri, '/'); $pathinfo = trim($pathinfo, '/'); + $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); + $pathinfo = trim($pathinfo, '/'); + $self = trim($self, '/'); + $self = preg_replace("|^$home_path|", '', $self); $self = str_replace($home_path, '', $self); $self = trim($self, '/');