From 7ab338d7f8ce8a400a11cf96390370ea0cf4c67e Mon Sep 17 00:00:00 2001 From: markjaquith Date: Wed, 12 Nov 2008 21:08:48 +0000 Subject: [PATCH] Catch more blank query string thing cases, without resorting to crazy regex. props filosofo. fixes #8098 git-svn-id: http://svn.automattic.com/wordpress/trunk@9645 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 1469dcf15d..728b1dda9f 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -204,7 +204,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); // Clean up empty query strings - $redirect['query'] = preg_replace( '#(^\??|&)(p|page_id|cat|tag)=?$#', '', $redirect['query'] ); + $redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&'); // Remove redundant leading ampersands $redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] );