Changeset 3360611
- Timestamp:
- 09/12/2025 03:17:43 PM (6 months ago)
- Location:
- wp-ultimate-csv-importer
- Files:
-
- 2 edited
-
tags/7.29/uploadModules/FtpUpload.php (modified) (2 diffs)
-
trunk/uploadModules/FtpUpload.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-ultimate-csv-importer/tags/7.29/uploadModules/FtpUpload.php
r3360428 r3360611 110 110 $path = isset($path[0]) ? $path[0] : ''; 111 111 $file_extension = pathinfo($ftp_file_name, PATHINFO_EXTENSION); 112 $allowed_exts = ['csv', 'xml', 'xlsx', 'xls', 'txt', 'tsv']; 113 if ( ! in_array( $file_extension, $allowed_exts, true ) ) { 114 wp_die( __( 'Invalid file type.', 'wp-ultimate-csv-importer' ), 400 ); 115 } 112 116 if(empty($file_extension)){ 113 117 $file_extension = 'xml'; … … 221 225 $response['message'] = $validate_file; 222 226 echo wp_json_encode($response); 223 unlink($path); 227 $upload_dir = wp_upload_dir(); 228 $base_dir = trailingslashit($upload_dir['basedir']); 229 230 $real_base = realpath($base_dir); 231 $real_path = realpath($path); 232 233 if ($real_path !== false && strpos($real_path, $real_base) === 0) { 234 unlink($real_path); // safe delete inside uploads only 235 } 224 236 $wpdb->get_results("UPDATE $file_table_name SET status='Download Failed' WHERE id = '$lastid'"); 225 237 } -
wp-ultimate-csv-importer/trunk/uploadModules/FtpUpload.php
r3357936 r3360611 110 110 $path = isset($path[0]) ? $path[0] : ''; 111 111 $file_extension = pathinfo($ftp_file_name, PATHINFO_EXTENSION); 112 $allowed_exts = ['csv', 'xml', 'xlsx', 'xls', 'txt', 'tsv']; 113 if ( ! in_array( $file_extension, $allowed_exts, true ) ) { 114 wp_die( __( 'Invalid file type.', 'wp-ultimate-csv-importer' ), 400 ); 115 } 112 116 if(empty($file_extension)){ 113 117 $file_extension = 'xml'; … … 221 225 $response['message'] = $validate_file; 222 226 echo wp_json_encode($response); 223 unlink($path); 227 $upload_dir = wp_upload_dir(); 228 $base_dir = trailingslashit($upload_dir['basedir']); 229 230 $real_base = realpath($base_dir); 231 $real_path = realpath($path); 232 233 if ($real_path !== false && strpos($real_path, $real_base) === 0) { 234 unlink($real_path); // safe delete inside uploads only 235 } 224 236 $wpdb->get_results("UPDATE $file_table_name SET status='Download Failed' WHERE id = '$lastid'"); 225 237 }
Note: See TracChangeset
for help on using the changeset viewer.