Skip to content

Commit e0fa48f

Browse files
Dik Takkennikic
Dik Takken
authored andcommitted
Deprecate libxml_disable_entity_loader()
This method was used to protect code against XXE processing attacks. Since PHP now requires libxml >= 2.9.0 external entity loading no longer needs to be disabled to prevent these attacks. It is disabled by default. Also, the method has an unwanted side effect that causes a lot of confusion: Parsing XML data from resources like files is no longer possible. Closes GH-5867.
1 parent 691a09f commit e0fa48f

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

UPGRADING

+5
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,11 @@ PHP 8.0 UPGRADE NOTES
799799
. enchant_broker_free and enchant_broker_free_dict, unset the object instead
800800
. ENCHANT_MYSPELL and ENCHANT_ISPELL constants
801801

802+
- LibXML:
803+
. libxml_disable_entity_loader() has been deprecated. As libxml 2.9.0 is now
804+
required, external entity loading is guaranteed to be disabled by default,
805+
and this function is no longer needed to protect against XXE attacks.
806+
802807
- PGSQL / PDO PGSQL:
803808
. The constant PG_VERSION_STR has now the same value as PG_VERSION, and thus
804809
is deprecated.

ext/libxml/libxml.stub.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function libxml_get_errors(): array {}
1313

1414
function libxml_clear_errors(): void {}
1515

16+
/** @deprecated */
1617
function libxml_disable_entity_loader(bool $disable = true): bool {}
1718

1819
function libxml_set_external_entity_loader(?callable $resolver_function): bool {}

ext/libxml/libxml_arginfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 2d793e5134ea8633c432f03d20c1d8b80a05795b */
2+
* Stub hash: ded229511dc2bc3912d35b8055c0fd69420baff0 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_libxml_set_streams_context, 0, 1, IS_VOID, 0)
55
ZEND_ARG_INFO(0, context)
@@ -42,7 +42,7 @@ static const zend_function_entry ext_functions[] = {
4242
ZEND_FE(libxml_get_last_error, arginfo_libxml_get_last_error)
4343
ZEND_FE(libxml_get_errors, arginfo_libxml_get_errors)
4444
ZEND_FE(libxml_clear_errors, arginfo_libxml_clear_errors)
45-
ZEND_FE(libxml_disable_entity_loader, arginfo_libxml_disable_entity_loader)
45+
ZEND_DEP_FE(libxml_disable_entity_loader, arginfo_libxml_disable_entity_loader)
4646
ZEND_FE(libxml_set_external_entity_loader, arginfo_libxml_set_external_entity_loader)
4747
ZEND_FE_END
4848
};

ext/libxml/tests/libxml_disable_entity_loader.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ echo "Done\n";
3333
?>
3434
--EXPECTF--
3535
bool(true)
36+
37+
Deprecated: Function libxml_disable_entity_loader() is deprecated in %s on line %d
3638
bool(false)
3739

3840
Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "%s" in %s on line %d

0 commit comments

Comments
 (0)