Fix: "Import file path is invalid" in Windows (#51456)

* Fix WC_Product_CSV_Importer_Controller::check_file_path failing on Windows
This commit is contained in:
Néstor Soriano 2024-09-18 13:15:15 +02:00 committed by GitHub
parent 3df48f2bd7
commit 16e072879b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix invalid path error in product importer in Windows

View File

@ -125,6 +125,7 @@ class WC_Product_CSV_Importer_Controller {
// Check that file is within an allowed location.
if ( $is_valid_file ) {
$normalized_path = wp_normalize_path( $path );
$in_valid_location = false;
$valid_locations = array();
$valid_locations[] = ABSPATH;
@ -135,7 +136,8 @@ class WC_Product_CSV_Importer_Controller {
}
foreach ( $valid_locations as $valid_location ) {
if ( 0 === stripos( $path, trailingslashit( realpath( $valid_location ) ) ) ) {
$normalized_location = wp_normalize_path( realpath( $valid_location ) );
if ( 0 === stripos( $normalized_path, trailingslashit( $normalized_location ) ) ) {
$in_valid_location = true;
break;
}