Ticket #28632: 28632.patch
| File 28632.patch, 3.0 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/link-template.php
2842 2842 * @since 3.4.0 2843 2843 * 2844 2844 * @param string $url Absolute url that includes a scheme 2845 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.2845 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', 'relative', or 'protocol_relative'. 2846 2846 * @return string $url URL with chosen scheme. 2847 2847 */ 2848 2848 function set_url_scheme( $url, $scheme = null ) { … … 2852 2852 $scheme = is_ssl() ? 'https' : 'http'; 2853 2853 } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) { 2854 2854 $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; 2855 } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) {2855 } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' && $scheme !== 'protocol_relative' ) { 2856 2856 $scheme = is_ssl() ? 'https' : 'http'; 2857 2857 } 2858 2858 … … 2864 2864 $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); 2865 2865 if ( $url !== '' && $url[0] === '/' ) 2866 2866 $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); 2867 } else if ( 'protocol_relative' == $scheme ) { 2868 $url = preg_replace( '#^\w+://#', '//', $url ); 2867 2869 } else { 2868 2870 $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); 2869 2871 } … … 2876 2878 * @param string $url The complete URL including scheme and path. 2877 2879 * @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'. 2878 2880 * @param string $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', 2879 * 'login_post', 'admin', 'rpc', or 'relative'.2881 * 'login_post', 'admin', 'rpc', 'relative', or 'protocol_relative'. 2880 2882 */ 2881 2883 return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); 2882 2884 } -
tests/phpunit/tests/url.php
239 239 '' 240 240 ); 241 241 242 $protocol_relative_links = array( 243 '//wordpress.org/', 244 '//wordpress.org/', 245 '//wordpress.org/news/', 246 '//wordpress.org' 247 ); 248 242 249 $forced_admin = force_ssl_admin(); 243 250 $forced_login = force_ssl_login(); 244 251 $i = 0; … … 246 253 $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'https' ) ); 247 254 $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'http' ) ); 248 255 $this->assertEquals( $relative_links[ $i ], set_url_scheme( $link, 'relative' ) ); 256 $this->assertEquals( $protocol_relative_links[ $i ], set_url_scheme( $link, 'protocol_relative' ) ); 249 257 250 258 $_SERVER['HTTPS'] = 'on'; 251 259 $this->assertEquals( $https_links[ $i ], set_url_scheme( $link ) );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)