Ticket #19918: 19918-circular-fragment.diff
File 19918-circular-fragment.diff, 1.3 KB (added by , 9 years ago) |
---|
-
wp-includes/canonical.php
494 494 $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url ); 495 495 496 496 // yes, again -- in case the filter aborted the request 497 if ( ! $redirect_url || $redirect_url == $requested_url) {497 if ( ! $redirect_url || strip_fragment_from_url($redirect_url) == strip_fragment_from_url($requested_url) ) { 498 498 return; 499 499 } 500 500 … … 540 540 } 541 541 542 542 /** 543 * Strips the #fragment from a URL, if one is present. 544 * 545 * @param string $url The URL to strip. 546 * @return string The altered URL. 547 */ 548 function strip_fragment_from_url( $url ) { 549 $parsed_url = @parse_url( $url ); 550 if ( !empty( $parsed_url['host'] ) ) { 551 // This mirrors code in redirect_canonical(). It does not handle every case. 552 $url = $parsed_url['scheme'] . '://' . $parsed_url['host']; 553 if ( !empty($parsed_url['port']) ) 554 $url .= ':' . $parsed_url['port']; 555 $redirect_url .= $parsed_url['path']; 556 if ( !empty($parsed_url['query']) ) 557 $url .= '?' . $parsed_url['query']; 558 } 559 560 return $url; 561 } 562 563 /** 543 564 * Attempts to guess the correct URL based on query vars 544 565 * 545 566 * @since 2.3.0