Fix IE Download via SSL bug and fix http file over SSL x-sendfile bug

This commit is contained in:
Ken Bass 2013-04-03 16:17:50 -04:00
parent 6e632c3348
commit 2906c1b7ee
1 changed files with 18 additions and 5 deletions

View File

@ -929,7 +929,7 @@ function woocommerce_download_product() {
if ( isset( $_GET['download_file'] ) && isset( $_GET['order'] ) && isset( $_GET['email'] ) ) { if ( isset( $_GET['download_file'] ) && isset( $_GET['order'] ) && isset( $_GET['email'] ) ) {
global $wpdb; global $wpdb, $is_IE;
$product_id = (int) urldecode($_GET['download_file']); $product_id = (int) urldecode($_GET['download_file']);
$order_key = urldecode( $_GET['order'] ); $order_key = urldecode( $_GET['order'] );
@ -1036,14 +1036,16 @@ function woocommerce_download_product() {
if ( ! is_multisite() ) { if ( ! is_multisite() ) {
/* /*
* If WP FORCE_SSL_ADMIN is enabled, file will have been inserted as https from Media Library * Download file may be either http or https.
* site_url() depends on whether the page containing the download (ie; My Account) is served via SSL. * site_url() depends on whether the page containing the download (ie; My Account) is served via SSL because WC
* So blindly doing a str_replace is incorrect because it will fail with schemes are mismatched. * modifies site_url() via a filter to force_ssl.
* So blindly doing a str_replace is incorrect because it will fail when schemes are mismatched. This code
* handles the various permutations.
*/ */
$scheme = parse_url( $file_path, PHP_URL_SCHEME ); $scheme = parse_url( $file_path, PHP_URL_SCHEME );
if ( $scheme ) { if ( $scheme ) {
$site_url = site_url( '', $scheme ); $site_url = set_url_scheme( site_url( '' ), $scheme );
} else { } else {
$site_url = is_ssl() ? str_replace( 'https:', 'http:', site_url() ) : site_url(); $site_url = is_ssl() ? str_replace( 'https:', 'http:', site_url() ) : site_url();
} }
@ -1104,6 +1106,17 @@ function woocommerce_download_product() {
@ob_end_clean(); // Zip corruption fix @ob_end_clean(); // Zip corruption fix
nocache_headers(); nocache_headers();
if ( $is_IE ) {
// IE bug prevents download via SSL when both Cache Control and Pragma no-cache headers set.
if ( function_exists( 'header_remove' ) ) {
// For PHP 5.3+
@header_remove( 'Pragma' );
} else {
// For PHP 5.2
header( 'Pragma:' );
}
}
$file_name = basename( $file_path ); $file_name = basename( $file_path );