]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/canonical.php
Wordpress 3.0.1
[autoinstalls/wordpress.git] / wp-includes / canonical.php
index 1cbf7d27b254cc4479603c798c26f2a9f63850ea..20520a41cc783c4cf7dc7ab4570f06eeea81c16b 100644 (file)
@@ -156,8 +156,8 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
 
                        $obj = $wp_query->get_queried_object();
 
 
                        $obj = $wp_query->get_queried_object();
 
-                       if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
-
+                       if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) )
+                                       && !is_wp_error($tax_url) && $redirect['query'] ) {
                                if ( is_category() ) {
                                        $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']);
                                } elseif ( is_tag() ) {
                                if ( is_category() ) {
                                        $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']);
                                } elseif ( is_tag() ) {
@@ -343,6 +343,16 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
 
        if ( !$redirect_url || $redirect_url == $requested_url )
                return false;
 
        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);
 
        // 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);