WordPress.org

Make WordPress Core

Changeset 9642


Ignore:
Timestamp:
11/12/2008 08:09:16 PM (10 years ago)
Author:
markjaquith
Message:

Be more picky about the trailing blank query string things we strip. props filosofo, fitztrev, stevish, azaozz, DD32 (go team!). fixes #8098. fixes #8180

File:
1 edited

Legend:

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

    r9590 r9642  
    201201
    202202    if ( !empty( $redirect['query'] ) ) {
    203         // Remove trailing slashes from certain terminating query string args
     203        // Remove trailing spaces from certain terminating query string args
    204204        $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
    205205
    206206        // Clean up empty query strings
    207         $redirect['query'] = preg_replace( '#&?(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
     207        $redirect['query'] = preg_replace( '#(^\??|&)(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
     208
     209        // Remove redundant leading ampersands
     210        $redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] );
    208211    }
    209212
Note: See TracChangeset for help on using the changeset viewer.