|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-11-12 20:02 UTC] jeremy at derusse dot com
Description: ------------ calling libxml_disable_entity_loader has been deprecated in PHP >= 8.0 (https://github.com/php/php-src/pull/5867) But if a 3rd party library disable the entity loader, we have no way to re-enable it (or even to know if we have to re-enable it) without triggering a deprecation. Suggested change: - do not trigger deprecation when calling the method with `false` - add a new method `libxml_entity_loader_disabled()` that returns true/false when the entity loader is disabled PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Not using deprecated libxml_disable_entity_loader leads to XXE vulnerability. My settings: Apache 2.4, Windows, PHP 8.0.0, libxml 2.9.10 Consider the following code: // --------------- $file = 'C:/secret/file.txt'; $xml = '<' . '?xml version="1.0" encoding="utf-8"?' .'>' .'<!DOCTYPE tag [<!ENTITY foo PUBLIC "bar" "'.$file.'" >]>' .'<tag>&foo;</tag>'; $prev = libxml_disable_entity_loader(TRUE); $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; $loadRes = $doc->loadXML($xml, LIBXML_NOENT); libxml_disable_entity_loader($prev); print $doc->saveXml(); // --------------- With libxml_disable_entity_loader, we get E_DEPRECATED, but the contents of local file is not loaded. Without libxml_disable_entity_loader, the code displays contents of local file. In our application, we want to allow local entities in XML document, so we have to call loadXml with LIBXML_NOENT flag.