Be more picky about the trailing blank query string things we strip. props filosofo, fitztrev, stevish, azaozz, DD32 (go team!). fixes #8098. fixes #8180

git-svn-id: http://svn.automattic.com/wordpress/trunk@9642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2008-11-12 20:09:16 +00:00
parent 41b43c1d03
commit 21eb85b469
1 changed files with 5 additions and 2 deletions

View File

@ -200,11 +200,14 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
if ( !empty( $redirect['query'] ) ) {
// Remove trailing slashes from certain terminating query string args
// Remove trailing spaces from certain terminating query string args
$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'] = preg_replace( '#(^\??|&)(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
// Remove redundant leading ampersands
$redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] );
}
// strip /index.php/ when we're not using PATHINFO permalinks