Merge pull request #21573 from woocommerce/fix/21548
Simplified path check for CSV importer to cause less issues
This commit is contained in:
commit
c994956f03
|
@ -91,7 +91,7 @@ class WC_Product_CSV_Importer_Controller {
|
|||
* @return bool
|
||||
*/
|
||||
public static function is_file_valid_csv( $file, $check_path = true ) {
|
||||
if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true ) && 0 !== stripos( $file, ABSPATH ) ) {
|
||||
if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true ) && false !== stripos( $file, '://' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,16 +27,6 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
|
|||
$bootstrap = WC_Unit_Tests_Bootstrap::instance();
|
||||
require_once $bootstrap->plugin_dir . '/includes/import/class-wc-product-csv-importer.php';
|
||||
require_once $bootstrap->plugin_dir . '/includes/admin/importers/class-wc-product-csv-importer-controller.php';
|
||||
|
||||
add_filter( 'woocommerce_product_csv_importer_check_import_file_path', '__return_false' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove filters.
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
remove_filter( 'woocommerce_product_csv_importer_check_import_file_path', '__return_false' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -624,4 +614,14 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
|
|||
|
||||
return $mocked_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WC_Product_CSV_Importer_Controller::is_file_valid_csv.
|
||||
*/
|
||||
public function test_is_file_valid_csv() {
|
||||
$this->assertTrue( WC_Product_CSV_Importer_Controller::is_file_valid_csv( 'C:/wamp64/www/test.local/wp-content/uploads/2018/10/products_all_gg-1.csv' ) );
|
||||
$this->assertTrue( WC_Product_CSV_Importer_Controller::is_file_valid_csv( '/srv/www/woodev/wp-content/uploads/2018/10/1098488_single.csv' ) );
|
||||
$this->assertFalse( WC_Product_CSV_Importer_Controller::is_file_valid_csv( '/srv/www/woodev/wp-content/uploads/2018/10/img.jpg' ) );
|
||||
$this->assertFalse( WC_Product_CSV_Importer_Controller::is_file_valid_csv( 'file:///srv/www/woodev/wp-content/uploads/2018/10/1098488_single.csv' ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue