Skip to content

Commit cae6edf

Browse files
Merge remote-tracking branch '36034/fix-for-issue-33422' into comm_voted_v3
2 parents be84993 + 2200c45 commit cae6edf

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

lib/internal/Magento/Framework/Convert/Excel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ protected function _getXmlRow($row, $useCallback)
150150

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

155156
/**
156157
* Security enhancement for CSV data processing by Excel-like applications.

lib/internal/Magento/Framework/Convert/Test/Unit/ExcelTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,37 @@
2020
class ExcelTest extends TestCase
2121
{
2222
/**
23-
* Test data
23+
* Test excel data
2424
*
2525
* @var array
2626
*/
2727
private $_testData = [
2828
[
2929
'ID', 'Name', 'Email', 'Group', 'Telephone', '+Telephone', 'ZIP', '0ZIP', 'Country', 'State/Province',
30-
'Symbol=', 'Symbol-', 'Symbol+'
30+
'Symbol=', 'Symbol-', 'Symbol+', 'NumberWithSpace', 'NumberWithTabulation'
3131
],
3232
[
3333
1, 'Jon Doe', '[email protected]', 'General', '310-111-1111', '+310-111-1111', 90232, '090232',
34-
'United States', 'California', '=', '-', '+'
34+
'United States', 'California', '=', '-', '+', ' 3111', '\t3111'
3535
],
3636
];
3737

38+
/**
39+
* @var string[]
40+
*/
3841
protected $_testHeader = [
3942
'HeaderID', 'HeaderName', 'HeaderEmail', 'HeaderGroup', 'HeaderPhone', 'Header+Phone', 'HeaderZIP',
40-
'Header0ZIP', 'HeaderCountry', 'HeaderRegion', 'HeaderSymbol=', 'HeaderSymbol-', 'HeaderSymbol+'
43+
'Header0ZIP', 'HeaderCountry', 'HeaderRegion', 'HeaderSymbol=', 'HeaderSymbol-', 'HeaderSymbol+',
44+
'HeaderNumberWithSpace', 'HeaderNumberWithTabulation'
4145
];
4246

47+
/**
48+
* @var string[]
49+
*/
4350
protected $_testFooter = [
4451
'FooterID', 'FooterName', 'FooterEmail', 'FooterGroup', 'FooterPhone', 'Footer+Phone', 'FooterZIP',
45-
'Footer0ZIP', 'FooterCountry', 'FooterRegion', 'FooterSymbol=', 'FooterSymbol-', 'FooterSymbol+'
52+
'Footer0ZIP', 'FooterCountry', 'FooterRegion', 'FooterSymbol=', 'FooterSymbol-', 'FooterSymbol+',
53+
'FooterNumberWithSpace', 'FooterNumberWithTabulation'
4654
];
4755

4856
/**

lib/internal/Magento/Framework/Convert/Test/Unit/_files/sample.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<Cell><Data ss:Type="String">HeaderSymbol=</Data></Cell>
3333
<Cell><Data ss:Type="String">HeaderSymbol-</Data></Cell>
3434
<Cell><Data ss:Type="String">HeaderSymbol+</Data></Cell>
35+
<Cell><Data ss:Type="String">HeaderNumberWithSpace</Data></Cell>
36+
<Cell><Data ss:Type="String">HeaderNumberWithTabulation</Data></Cell>
3537
</Row>
3638
<Row>
3739
<Cell><Data ss:Type="String">ID</Data></Cell>
@@ -47,6 +49,8 @@
4749
<Cell><Data ss:Type="String">Symbol=</Data></Cell>
4850
<Cell><Data ss:Type="String">Symbol-</Data></Cell>
4951
<Cell><Data ss:Type="String">Symbol+</Data></Cell>
52+
<Cell><Data ss:Type="String">NumberWithSpace</Data></Cell>
53+
<Cell><Data ss:Type="String">NumberWithTabulation</Data></Cell>
5054
</Row>
5155
<Row>
5256
<Cell><Data ss:Type="Number">1</Data></Cell>
@@ -62,6 +66,8 @@
6266
<Cell><Data ss:Type="String"> =</Data></Cell>
6367
<Cell><Data ss:Type="String"> -</Data></Cell>
6468
<Cell><Data ss:Type="String"> +</Data></Cell>
69+
<Cell><Data ss:Type="String"> 3111</Data></Cell>
70+
<Cell><Data ss:Type="String">\t3111</Data></Cell>
6571
</Row>
6672
<Row>
6773
<Cell><Data ss:Type="String">FooterID</Data></Cell>
@@ -77,6 +83,8 @@
7783
<Cell><Data ss:Type="String">FooterSymbol=</Data></Cell>
7884
<Cell><Data ss:Type="String">FooterSymbol-</Data></Cell>
7985
<Cell><Data ss:Type="String">FooterSymbol+</Data></Cell>
86+
<Cell><Data ss:Type="String">FooterNumberWithSpace</Data></Cell>
87+
<Cell><Data ss:Type="String">FooterNumberWithTabulation</Data></Cell>
8088
</Row>
8189
</Table>
8290
</Worksheet>

0 commit comments

Comments
 (0)