Skip to content

Commit

Permalink
Hex octets are case-insenstive. Don't 301 when only the octet case di…
Browse files Browse the repository at this point in the history
…ffers. Props hakre. fixes #14292 for 3.0.1

git-svn-id: https://develop.svn.wordpress.org/branches/3.0@15438 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
ryanboren committed Jul 18, 2010
1 parent 95d6861 commit 7362369
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wp-includes/canonical.php
Expand Up @@ -343,6 +343,16 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {

if ( !$redirect_url || $redirect_url == $requested_url )
return false;

// Hex encoded octets are case-insensitive.
if ( false !== strpos($requested_url, '%') ) {
if ( !function_exists('lowercase_octets') ) {
function lowercase_octets($matches) {
return strtolower( $matches[0] );
}
}
$requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url);
}

// Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
Expand Down

0 comments on commit 7362369

Please sign in to comment.