Ticket #15928: 15928.6.patch
File 15928.6.patch, 4.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/media-views.js
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js index 62d2e43..809ccd2 100644
7459 7459 }, 7460 7460 7461 7461 updateImage: function() { 7462 this.$('img').attr( 'src', this.model.get(' url') );7462 this.$('img').attr( 'src', this.model.get('src_url') ); 7463 7463 } 7464 7464 }); 7465 7465 -
src/wp-includes/link-template.php
diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php index 235fa79..72c20cb 100644
function self_admin_url($path = '', $scheme = 'admin') { 3032 3032 * @since 3.4.0 3033 3033 * 3034 3034 * @param string $url Absolute url that includes a scheme 3035 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.3035 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', 'relative', or 'network_path'. 3036 3036 * @return string $url URL with chosen scheme. 3037 3037 */ 3038 3038 function set_url_scheme( $url, $scheme = null ) { … … function set_url_scheme( $url, $scheme = null ) { 3042 3042 $scheme = is_ssl() ? 'https' : 'http'; 3043 3043 } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) { 3044 3044 $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; 3045 } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) {3045 } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' && $scheme !== 'network_path' ) { 3046 3046 $scheme = is_ssl() ? 'https' : 'http'; 3047 3047 } 3048 3048 … … function set_url_scheme( $url, $scheme = null ) { 3054 3054 $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); 3055 3055 if ( $url !== '' && $url[0] === '/' ) 3056 3056 $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); 3057 } else if ( 'network_path' == $scheme ) { 3058 $url = preg_replace( '#^\w+://#', '//', $url ); 3057 3059 } else { 3058 3060 $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); 3059 3061 } -
src/wp-includes/media.php
diff --git src/wp-includes/media.php src/wp-includes/media.php index 0c3fd22..fcce20a 100644
function wp_prepare_attachment_for_js( $attachment ) { 2588 2588 'title' => $attachment->post_title, 2589 2589 'filename' => wp_basename( $attachment->guid ), 2590 2590 'url' => $attachment_url, 2591 'src_url' => set_url_scheme( $attachment_url, 'network_path' ), 2591 2592 'link' => get_attachment_link( $attachment->ID ), 2592 2593 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), 2593 2594 'author' => $attachment->post_author, -
src/wp-includes/post.php
diff --git src/wp-includes/post.php src/wp-includes/post.php index f97318e..4d201b3 100644
function wp_get_attachment_url( $post_id = 0 ) { 4944 4944 $url = get_the_guid( $post->ID ); 4945 4945 } 4946 4946 4947 // Match the current scheme. 4948 $url = set_url_scheme( $url ); 4949 4947 4950 /** 4948 4951 * Filter the attachment URL. 4949 4952 * -
tests/phpunit/tests/post/attachments.php
diff --git tests/phpunit/tests/post/attachments.php tests/phpunit/tests/post/attachments.php index d079654..fe716e6 100644
class Tests_Post_Attachments extends WP_UnitTestCase { 278 278 $this->assertEquals( $attachment->post_parent, $post_id ); 279 279 } 280 280 281 /** 282 * @ticket 15928 283 */ 284 public function test_wp_get_attachment_url_on_front_end_with_https_off() { 285 $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); 286 $contents = file_get_contents( $filename ); 287 288 $upload = wp_upload_bits( basename( $filename ), null, $contents ); 289 $this->assertTrue( empty( $upload['error'] ) ); 290 291 // Set attachment ID 292 $attachment_id = $this->_make_attachment( $upload ); 293 294 $is_ssl = is_ssl(); 295 $_SERVER['HTTPS'] = 'off'; 296 297 // Test non-admin pages 298 set_current_screen( 'front' ); 299 $url = wp_get_attachment_url( $attachment_id ); 300 $this->assertSame( $url, set_url_scheme( $url, 'http' ) ); 301 302 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off'; 303 } 304 305 /** 306 * @ticket 15928 307 */ 308 public function test_wp_get_attachment_url_on_front_end_with_https_on() { 309 $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); 310 $contents = file_get_contents( $filename ); 311 312 $upload = wp_upload_bits( basename( $filename ), null, $contents ); 313 $this->assertTrue( empty( $upload['error'] ) ); 314 315 // Set attachment ID 316 $attachment_id = $this->_make_attachment( $upload ); 317 318 $is_ssl = is_ssl(); 319 $_SERVER['HTTPS'] = 'on'; 320 321 // Test non-admin pages 322 set_current_screen( 'front' ); 323 $url = wp_get_attachment_url( $attachment_id ); 324 $this->assertSame( $url, set_url_scheme( $url, 'https' ) ); 325 326 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off'; 327 } 281 328 }