From 7d1aad0ea1d27f71eff1b41f2a74377e124914c7 Mon Sep 17 00:00:00 2001 From: GrigoreMihai Date: Mon, 22 Apr 2024 21:59:46 +0300 Subject: [PATCH] fix: checking file extension exists before type validation --- inc/files.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/files.php b/inc/files.php index 3c007927..1e847605 100644 --- a/inc/files.php +++ b/inc/files.php @@ -94,7 +94,7 @@ function ppom_create_thumb_for_meta( $file_name, $product_id, $cropped = false, $edited_thumb_path = ppom_get_dir_path() . 'edits/thumbs/' . $file_name; if ( file_exists( $edited_thumb_path ) ) { $file_thumb_url = ppom_get_dir_url() . 'edits/thumbs/' . $file_name; - } + } } elseif ( file_exists( $file_dir_path ) && $post_type == 'shop_order' ) { $file_link = $file_thumb_url; } else { @@ -177,7 +177,7 @@ function ppom_upload_file() { $restricted_type = ppom_get_option( 'ppom_restricted_file_type', $default_restricted ); $restricted_type = explode( ',', $restricted_type ); - if ( in_array( strtolower( $extension ), $restricted_type ) ) { + if ( empty( $extension ) || in_array( strtolower( $extension ), $restricted_type ) ) { $response ['status'] = 'error'; $response ['message'] = __( 'File type not valid - ' . $extension, 'woocommerce-product-addon' ); wp_send_json( $response ); @@ -372,7 +372,7 @@ function ppom_delete_file() { _e( 'File removed', 'woocommerce-product-addon' ); } else { printf( __( 'Error while deleting file %s', 'woocommerce-product-addon' ), $file_path ); - } + } } else { printf( __( 'Error while deleting file %s', 'woocommerce-product-addon' ), $file_path ); }