mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Strip trailing spaces in URLs, redirect to canonical URL. fixes #7537
git-svn-id: http://svn.automattic.com/wordpress/trunk@8667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
facedb8d81
commit
f4f6fb2019
@ -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