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:
parent
3df48f2bd7
commit
16e072879b
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix invalid path error in product importer in Windows
|
|
@ -125,6 +125,7 @@ class WC_Product_CSV_Importer_Controller {
|
||||||
|
|
||||||
// Check that file is within an allowed location.
|
// Check that file is within an allowed location.
|
||||||
if ( $is_valid_file ) {
|
if ( $is_valid_file ) {
|
||||||
|
$normalized_path = wp_normalize_path( $path );
|
||||||
$in_valid_location = false;
|
$in_valid_location = false;
|
||||||
$valid_locations = array();
|
$valid_locations = array();
|
||||||
$valid_locations[] = ABSPATH;
|
$valid_locations[] = ABSPATH;
|
||||||
|
@ -135,7 +136,8 @@ class WC_Product_CSV_Importer_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $valid_locations as $valid_location ) {
|
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;
|
$in_valid_location = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue