Merge pull request #20041 from woocommerce/fix/20039
Wrap cell in ' rather than prepend
This commit is contained in:
commit
ad24b9c9d9
|
@ -354,7 +354,7 @@ abstract class WC_CSV_Exporter {
|
|||
$active_content_triggers = array( '=', '+', '-', '@' );
|
||||
|
||||
if ( in_array( mb_substr( $data, 0, 1 ), $active_content_triggers, true ) ) {
|
||||
$data = "'" . $data;
|
||||
$data = "'" . $data . "'";
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
|
@ -771,12 +771,11 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
|
|||
*/
|
||||
protected function unescape_negative_number( $value ) {
|
||||
if ( 0 === strpos( $value, "'-" ) ) {
|
||||
$unescaped = substr_replace( $value, '', 0, 1 );
|
||||
$unescaped = trim( $value, "'" );
|
||||
if ( is_numeric( $unescaped ) ) {
|
||||
return $unescaped;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
|
|||
$exporter = new WC_Product_CSV_Exporter();
|
||||
|
||||
$data = "=cmd|' /C calc'!A0";
|
||||
$this->assertEquals( "'=cmd|' /C calc'!A0", $exporter->escape_data( $data ) );
|
||||
$this->assertEquals( "'=cmd|' /C calc'!A0'", $exporter->escape_data( $data ) );
|
||||
|
||||
$data = "+cmd|' /C calc'!A0";
|
||||
$this->assertEquals( "'+cmd|' /C calc'!A0", $exporter->escape_data( $data ) );
|
||||
$this->assertEquals( "'+cmd|' /C calc'!A0'", $exporter->escape_data( $data ) );
|
||||
|
||||
$data = "-cmd|' /C calc'!A0";
|
||||
$this->assertEquals( "'-cmd|' /C calc'!A0", $exporter->escape_data( $data ) );
|
||||
$this->assertEquals( "'-cmd|' /C calc'!A0'", $exporter->escape_data( $data ) );
|
||||
|
||||
$data = "@cmd|' /C calc'!A0";
|
||||
$this->assertEquals( "'@cmd|' /C calc'!A0", $exporter->escape_data( $data ) );
|
||||
$this->assertEquals( "'@cmd|' /C calc'!A0'", $exporter->escape_data( $data ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue