mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that libxml_disable_entity_loader()
has been deprecated as of PHP 8.0.0. (#3814)
close https://github.com/hyperf/hyperf/issues/3813 Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
21d245c1aa
commit
84679ddc0c
@ -87,3 +87,4 @@
|
||||
- [#3788](https://github.com/hyperf/hyperf/pull/3788) Fixed type error when using `BladeCompiler::getRawPlaceholder()`.
|
||||
- [#3794](https://github.com/hyperf/hyperf/pull/3794) Fixed bug that `retry_interval` does not work for `rpc-multiplex`.
|
||||
- [#3798](https://github.com/hyperf/hyperf/pull/3798) Fixed bug that amqp consumer couldn't restart when rabbitmq server stopped.
|
||||
- [#3814](https://github.com/hyperf/hyperf/pull/3814) Fixed bug that `libxml_disable_entity_loader()` has been deprecated as of PHP 8.0.0.
|
||||
|
@ -49,9 +49,18 @@ class Xml
|
||||
|
||||
public static function toArray($xml)
|
||||
{
|
||||
$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
|
||||
$respObject = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
||||
libxml_disable_entity_loader($disableLibxmlEntityLoader);
|
||||
// For PHP 8.0, libxml_disable_entity_loader() has been deprecated.
|
||||
// As libxml 2.9.0 is now required, external entity loading is guaranteed to be disabled by default.
|
||||
// And this function is no longer needed to protect against XXE attacks, unless the (still vulnerable). LIBXML_NOENT is used.
|
||||
// In that case, it is recommended to refactor the code using libxml_set_external_entity_loader() to suppress loading of external entities.
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
|
||||
$respObject = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
||||
libxml_disable_entity_loader($disableLibxmlEntityLoader);
|
||||
} else {
|
||||
$respObject = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
||||
}
|
||||
|
||||
if ($respObject === false) {
|
||||
throw new InvalidArgumentException('Syntax error.');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user