Skip to content

Commit

Permalink
fix: checking file extension exists before type validation
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoreMihai committed Apr 22, 2024
1 parent 88bcf56 commit 7d1aad0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inc/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 7d1aad0

Please sign in to comment.