Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Convert/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ protected function _getXmlRow($row, $useCallback)

foreach ($row as $value) {
$value = $this->escaper->escapeHtml($value);
$dataType = is_numeric($value) && $value[0] !== '+' && $value[0] !== '0' ? 'Number' : 'String';
$dataType = is_numeric($value) && (is_string($value) && ctype_space($value[0]) === false) &&
$value[0] !== '+' && $value[0] !== '0' ? 'Number' : 'String';

/**
* Security enhancement for CSV data processing by Excel-like applications.
Expand Down
18 changes: 13 additions & 5 deletions lib/internal/Magento/Framework/Convert/Test/Unit/ExcelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,37 @@
class ExcelTest extends TestCase
{
/**
* Test data
* Test excel data
*
* @var array
*/
private $_testData = [
[
'ID', 'Name', 'Email', 'Group', 'Telephone', '+Telephone', 'ZIP', '0ZIP', 'Country', 'State/Province',
'Symbol=', 'Symbol-', 'Symbol+'
'Symbol=', 'Symbol-', 'Symbol+', 'NumberWithSpace', 'NumberWithTabulation'
],
[
1, 'Jon Doe', '[email protected]', 'General', '310-111-1111', '+310-111-1111', 90232, '090232',
'United States', 'California', '=', '-', '+'
'United States', 'California', '=', '-', '+', ' 3111', '\t3111'
],
];

/**
* @var string[]
*/
protected $_testHeader = [
'HeaderID', 'HeaderName', 'HeaderEmail', 'HeaderGroup', 'HeaderPhone', 'Header+Phone', 'HeaderZIP',
'Header0ZIP', 'HeaderCountry', 'HeaderRegion', 'HeaderSymbol=', 'HeaderSymbol-', 'HeaderSymbol+'
'Header0ZIP', 'HeaderCountry', 'HeaderRegion', 'HeaderSymbol=', 'HeaderSymbol-', 'HeaderSymbol+',
'HeaderNumberWithSpace', 'HeaderNumberWithTabulation'
];

/**
* @var string[]
*/
protected $_testFooter = [
'FooterID', 'FooterName', 'FooterEmail', 'FooterGroup', 'FooterPhone', 'Footer+Phone', 'FooterZIP',
'Footer0ZIP', 'FooterCountry', 'FooterRegion', 'FooterSymbol=', 'FooterSymbol-', 'FooterSymbol+'
'Footer0ZIP', 'FooterCountry', 'FooterRegion', 'FooterSymbol=', 'FooterSymbol-', 'FooterSymbol+',
'FooterNumberWithSpace', 'FooterNumberWithTabulation'
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<Cell><Data ss:Type="String">HeaderSymbol=</Data></Cell>
<Cell><Data ss:Type="String">HeaderSymbol-</Data></Cell>
<Cell><Data ss:Type="String">HeaderSymbol+</Data></Cell>
<Cell><Data ss:Type="String">HeaderNumberWithSpace</Data></Cell>
<Cell><Data ss:Type="String">HeaderNumberWithTabulation</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">ID</Data></Cell>
Expand All @@ -47,6 +49,8 @@
<Cell><Data ss:Type="String">Symbol=</Data></Cell>
<Cell><Data ss:Type="String">Symbol-</Data></Cell>
<Cell><Data ss:Type="String">Symbol+</Data></Cell>
<Cell><Data ss:Type="String">NumberWithSpace</Data></Cell>
<Cell><Data ss:Type="String">NumberWithTabulation</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">1</Data></Cell>
Expand All @@ -62,6 +66,8 @@
<Cell><Data ss:Type="String"> =</Data></Cell>
<Cell><Data ss:Type="String"> -</Data></Cell>
<Cell><Data ss:Type="String"> +</Data></Cell>
<Cell><Data ss:Type="String"> 3111</Data></Cell>
<Cell><Data ss:Type="String">\t3111</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">FooterID</Data></Cell>
Expand All @@ -77,6 +83,8 @@
<Cell><Data ss:Type="String">FooterSymbol=</Data></Cell>
<Cell><Data ss:Type="String">FooterSymbol-</Data></Cell>
<Cell><Data ss:Type="String">FooterSymbol+</Data></Cell>
<Cell><Data ss:Type="String">FooterNumberWithSpace</Data></Cell>
<Cell><Data ss:Type="String">FooterNumberWithTabulation</Data></Cell>
</Row>
</Table>
</Worksheet>
Expand Down