mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-21 04:00:44 +00:00
* Using htmlspecialchars to fix issue #3145: this prevents the SimpleXMLElement error "unterminated entity reference" when HTML entities are present in a worksheet * replace htmlspecialchars with proposal of oleibman * eliminate string cast, because PhpStan has a problem with that * ignore string cast for phpstan + enhance unit test
This commit is contained in:
@@ -940,7 +940,10 @@ class Xlsx extends BaseReader
|
||||
}
|
||||
$node->addAttribute('sqref', $item->children(Namespaces::DATA_VALIDATIONS2)->sqref);
|
||||
if (isset($item->formula1)) {
|
||||
$node->addChild('formula1', $item->formula1->children(Namespaces::DATA_VALIDATIONS2)->f);
|
||||
$childNode = $node->addChild('formula1');
|
||||
if ($childNode !== null) { // null should never happen
|
||||
$childNode[0] = (string) $item->formula1->children(Namespaces::DATA_VALIDATIONS2)->f; // @phpstan-ignore-line
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue3145Test extends TestCase
|
||||
{
|
||||
public function testIssue3145(): void
|
||||
{
|
||||
$filename = 'tests/data/Reader/XLSX/issue.3145.xlsx';
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($filename);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
self::assertEquals('Headline A', $sheet->getCell('A1')->getValue());
|
||||
self::assertEquals('Configdential B', $sheet->getCell('A2')->getValue());
|
||||
self::assertSame('OFFSET(INDIRECT(SUBSTITUTE($A2," ","")),0,0,COUNTA(INDIRECT(SUBSTITUTE($A2," ","")&"Col")),1)', $sheet->getCell('B2')->getDataValidation()->getFormula1());
|
||||
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user