Merge pull request #20041 from woocommerce/fix/20039

Wrap cell in ' rather than prepend
This commit is contained in:
Gerhard Potgieter 2018-05-18 12:27:26 +01:00 committed by GitHub
commit ad24b9c9d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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 ) );
}
/**