Make WordPress Core


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

File:
1 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() )
Note: See TracChangeset for help on using the changeset viewer.