WordPress.org

Make WordPress Core

Ticket #7537: trailing-spaces-canonical.diff

File trailing-spaces-canonical.diff, 1.6 KB (added by markjaquith, 6 years ago)
  • wp-includes/query.php

     
    524524                $qv['w'] = absint($qv['w']); 
    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']); 
    529531                if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']); 
  • wp-includes/canonical.php

     
    153153        // trailing /index.php/ 
    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() ) 
    158167                $redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);