WordPress.org

Make WordPress Core

Changeset 31838


Ignore:
Timestamp:
03/20/2015 01:01:52 AM (6 years ago)
Author:
pento
Message:

If the URL being visited has non-breaking spaces at the end of it, they were probably inserted by an errant URL copy/paste. Instead of showing a 404 for no obvious reason, let's just trim them.

Fixes #31499

File:
1 edited

Legend:

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

    r31459 r31838  
    8383    if ( !isset($redirect['query']) )
    8484        $redirect['query'] = '';
     85
     86    // If the original URL ended with non-breaking spaces, they were almost
     87    // certainly inserted by accident. Let's remove them, so the reader doesn't
     88    // see a 404 error with no obvious cause.
     89    $redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] );
    8590
    8691    // It's not a preview, so remove it from URL
Note: See TracChangeset for help on using the changeset viewer.