Make WordPress Core

Changeset 8667


Ignore:
Timestamp:
08/19/2008 03:21:12 AM (16 years ago)
Author:
markjaquith
Message:

Strip trailing spaces in URLs, redirect to canonical URL. fixes #7537

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r8593 r8667  
    154154    $redirect['path'] = preg_replace('|/index.php/$|', '/', $redirect['path']);
    155155
     156    // Remove trailing spaces from the path
     157    $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
     158
     159    // Remove trailing slashes from certain terminating query string args
     160    $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
     161
     162    // Clean up empty query strings
     163    $redirect['query'] = preg_replace( '#&?(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
     164
    156165    // strip /index.php/ when we're not using PATHINFO permalinks
    157166    if ( !$wp_rewrite->using_index_permalinks() )
  • trunk/wp-includes/query.php

    r8646 r8667  
    525525        $qv['m'] = absint($qv['m']);
    526526        $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
     527        $qv['pagename'] = trim( $qv['pagename'] );
     528        $qv['name'] = trim( $qv['name'] );
    527529        if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
    528530        if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
Note: See TracChangeset for help on using the changeset viewer.