Strip trailing spaces in URLs, redirect to canonical URL. fixes #7537
git-svn-id: https://develop.svn.wordpress.org/trunk@8667 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f104c612cb
commit
71632ab8c7
@ -153,6 +153,15 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
||||
// trailing /index.php/
|
||||
$redirect['path'] = preg_replace('|/index.php/$|', '/', $redirect['path']);
|
||||
|
||||
// Remove trailing spaces from the path
|
||||
$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
|
||||
|
||||
// Remove trailing slashes 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'] );
|
||||
|
||||
// strip /index.php/ when we're not using PATHINFO permalinks
|
||||
if ( !$wp_rewrite->using_index_permalinks() )
|
||||
$redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);
|
||||
|
@ -524,6 +524,8 @@ class WP_Query {
|
||||
$qv['w'] = absint($qv['w']);
|
||||
$qv['m'] = absint($qv['m']);
|
||||
$qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
|
||||
$qv['pagename'] = trim( $qv['pagename'] );
|
||||
$qv['name'] = trim( $qv['name'] );
|
||||
if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
|
||||
if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
|
||||
if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
|
||||
|
Loading…
Reference in New Issue
Block a user