phpcs cleanup
This commit is contained in:
parent
0a9e15ca69
commit
5854ce3738
|
@ -4,11 +4,11 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||||
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||||
use PhpOffice\PhpSpreadsheet\Settings;
|
use PhpOffice\PhpSpreadsheet\Settings;
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Exception;
|
||||||
class XmlScanner
|
class XmlScanner
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Identifies whether the thread-safe libxmlDisableEntityLoader() function is available
|
* Identifies whether the thread-safe libxmlDisableEntityLoader() function is available.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -30,12 +30,13 @@ class XmlScanner
|
||||||
if (PHP_MAJOR_VERSION > 7) {
|
if (PHP_MAJOR_VERSION > 7) {
|
||||||
switch (PHP_MINOR_VERSION) {
|
switch (PHP_MINOR_VERSION) {
|
||||||
case 2:
|
case 2:
|
||||||
return (PHP_RELEASE_VERSION >= 1);
|
return PHP_RELEASE_VERSION >= 1;
|
||||||
case 1:
|
case 1:
|
||||||
return (PHP_RELEASE_VERSION >= 13);
|
return PHP_RELEASE_VERSION >= 13;
|
||||||
case 0:
|
case 0:
|
||||||
return (PHP_RELEASE_VERSION >= 27);
|
return PHP_RELEASE_VERSION >= 27;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +46,14 @@ class XmlScanner
|
||||||
/**
|
/**
|
||||||
* Scan the XML for use of <!ENTITY to prevent XXE/XEE attacks.
|
* Scan the XML for use of <!ENTITY to prevent XXE/XEE attacks.
|
||||||
*
|
*
|
||||||
* @param string $filestream
|
* @param mixed $xml
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function scan($xml) {
|
public function scan($xml)
|
||||||
|
{
|
||||||
$pattern = '/encoding="(.*?)"/';
|
$pattern = '/encoding="(.*?)"/';
|
||||||
$result = preg_match($pattern, $xml, $matches);
|
$result = preg_match($pattern, $xml, $matches);
|
||||||
$charset = $result ? $matches[1] : 'UTF-8';
|
$charset = $result ? $matches[1] : 'UTF-8';
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Security;
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Security;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class XmlScannerTest extends TestCase
|
class XmlScannerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,6 @@ class XmlScannerTest extends TestCase
|
||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerInvalidXML
|
* @dataProvider providerInvalidXML
|
||||||
*
|
*
|
||||||
|
@ -55,4 +54,4 @@ class XmlScannerTest extends TestCase
|
||||||
|
|
||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\BaseReader;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\Xml;
|
use PhpOffice\PhpSpreadsheet\Reader\Xml;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue