Merge pull request #2871 from krbvroc1/IE_download_fix

Fix IE Download via SSL bug and fix http file over SSL x-sendfile bug
This commit is contained in:
Mike Jolley 2013-04-04 09:13:13 -07:00
commit f93c1b6857
1 changed files with 16 additions and 13 deletions

View File

@ -927,7 +927,7 @@ function woocommerce_download_product() {
if ( isset( $_GET['download_file'] ) && isset( $_GET['order'] ) && isset( $_GET['email'] ) ) {
global $wpdb;
global $wpdb, $is_IE;
$product_id = (int) urldecode($_GET['download_file']);
$order_key = urldecode( $_GET['order'] );
@ -1034,19 +1034,16 @@ function woocommerce_download_product() {
if ( ! is_multisite() ) {
/*
* If WP FORCE_SSL_ADMIN is enabled, file will have been inserted as https from Media Library
* site_url() depends on whether the page containing the download (ie; My Account) is served via SSL.
* So blindly doing a str_replace is incorrect because it will fail with schemes are mismatched.
* 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 because WC
* 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 );
/*
* Because we sometimes 'force_ssl', do a http/https substituation manually here
*/
if ( $scheme == 'http' ) {
$site_url = str_replace( 'https:', 'http:', site_url( '', $scheme ) );
} elseif ( $scheme ) {
$site_url = site_url( '', $scheme );
if ( $scheme ) {
$site_url = set_url_scheme( site_url( '' ), $scheme );
} else {
$site_url = is_ssl() ? str_replace( 'https:', 'http:', site_url() ) : site_url();
}
@ -1106,7 +1103,13 @@ function woocommerce_download_product() {
if ( ob_get_level() )
@ob_end_clean(); // Zip corruption fix
nocache_headers();
if ( $is_IE && is_ssl() ) {
// IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Cache-Control: private' );
} else {
nocache_headers();
}
$file_name = basename( $file_path );