[2.3] Fix check for relative downloadable product path, closes #8612

This commit is contained in:
Claudio Sanches 2015-07-20 13:56:28 -03:00
parent 6781f37fed
commit 0eac4914df
1 changed files with 4 additions and 1 deletions

View File

@ -1163,7 +1163,10 @@ class WC_Meta_Box_Product_Data {
// Validate the file exists
if ( 'relative' === $file_is ) {
$_file_url = '..' === substr( $file_url, 0, 2 ) ? realpath( ABSPATH . $file_url ) : $file_url;
$_file_url = $file_url;
if ( '..' === substr( $file_url, 0, 2 ) || '/' !== substr( $file_url, 0, 1 ) ) {
$_file_url = realpath( ABSPATH . $file_url );
}
if ( ! 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' ), '<code>' . $file_url . '</code>' ) );