When converting an XMLReader node to a SimpleXMLElement, the conversion would automatically decode the XML entities. This resulted in a double decode. For example: """ was converted to """ when imported into a SimpleXMLElement and was again converted into " (quote). This commit changes the way the XLSX Shared Strings file is processed. It also changes the unescaping logic for both XLSX and ODS. Finally, it removes any usage of the SimpleXML library (yay!).
43 lines
985 B
PHP
43 lines
985 B
PHP
<?php
|
||
|
||
namespace Box\Spout\Common\Escaper;
|
||
|
||
/**
|
||
* Class ODSTest
|
||
*
|
||
* @package Box\Spout\Common\Escaper
|
||
*/
|
||
class ODSTest extends \PHPUnit_Framework_TestCase
|
||
{
|
||
/**
|
||
* @return array
|
||
*/
|
||
public function dataProviderForTestEscape()
|
||
{
|
||
return [
|
||
['test', 'test'],
|
||
['carl\'s "pokemon"', 'carl\'s "pokemon"'],
|
||
["\n", "\n"],
|
||
["\r", "\r"],
|
||
["\t", "\t"],
|
||
["\v", "<EFBFBD>"],
|
||
["\f", "<EFBFBD>"],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @dataProvider dataProviderForTestEscape
|
||
*
|
||
* @param string $stringToEscape
|
||
* @param string $expectedEscapedString
|
||
* @return void
|
||
*/
|
||
public function testEscape($stringToEscape, $expectedEscapedString)
|
||
{
|
||
$escaper = \Box\Spout\Common\Escaper\ODS::getInstance();
|
||
$escapedString = $escaper->escape($stringToEscape);
|
||
|
||
$this->assertEquals($expectedEscapedString, $escapedString, 'Incorrect escaped string');
|
||
}
|
||
}
|