Files
oleibman 32cb9f488f Excel 2003 Allows Html Entities
Fix #2157. Excel 2003 format allows some things which a real Xml parser would reject. In particular, it permits Html entities, and leading whitespace. Change Xml Reader to do likewise.
2024-10-06 09:32:11 -07:00

30 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xml;
use PhpOffice\PhpSpreadsheet\Reader\Xml as XmlReader;
use PHPUnit\Framework\TestCase;
class HtmlEntitiesLoadTest extends TestCase
{
public static function testIssue2157(): void
{
$infile = 'tests/data/Reader/Xml/issue.2157.small.xml';
$contents = (string) file_get_contents($infile);
self::assertSame("\t", substr($contents, 0, 1));
self::assertStringContainsString('&Tau;', $contents);
self::assertStringContainsString('&lt;/br&gt', $contents);
self::assertStringNotContainsString('Τ', $contents); // that's a Tau, not T
self::assertStringNotContainsString('</br>', $contents);
$reader = new XmlReader();
$spreadsheet = $reader->load($infile);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('Τέλεια όραση χωρίς γυαλιά', $sheet->getCell('E2')->getValue());
$g2 = $sheet->getCell('G2')->getValue();
self::assertStringContainsString('</br>', $g2);
$spreadsheet->disconnectWorksheets();
}
}