[2.3] Fixed download URL for relative paths, closes #8503

This commit is contained in:
Claudio Sanches 2015-07-06 14:59:28 -03:00
parent ffd63efbe2
commit e888294caa
1 changed files with 7 additions and 3 deletions

View File

@ -1281,10 +1281,14 @@ 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 ) ) {
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' ), '<code>' . $file_url . '</code>' ) );
continue;
}
}
$files[ $file_hash ] = array(
'name' => $file_name,