From e888294caafd7ac85cb69969814a4bd4ccccb4f8 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 6 Jul 2015 14:59:28 -0300 Subject: [PATCH] [2.3] Fixed download URL for relative paths, closes #8503 --- .../meta-boxes/class-wc-meta-box-product-data.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php index ff9cef5cb6d..705f05d79ad 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php @@ -1281,9 +1281,13 @@ class WC_Meta_Box_Product_Data { } // Validate the file exists - if ( 'relative' === $file_is && ! apply_filters( 'woocommerce_downloadable_file_exists', file_exists( $file_url ), $file_url ) ) { - WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '' . $file_url . '' ) ); - continue; + if ( 'relative' === $file_is ) { + $_file_exists = '..' === substr( $file_url, 0, 2 ) ? file_exists( realpath( ABSPATH . $file_url ) ) : file_exists( $file_url ); + + if ( ! apply_filters( 'woocommerce_downloadable_file_exists', $_file_exists, $file_url ) ) { + WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '' . $file_url . '' ) ); + continue; + } } $files[ $file_hash ] = array(