1 #include "php_snuffleupagus.h"
2
PHP_FUNCTION(sp_libxml_disable_entity_loader)3 PHP_FUNCTION(sp_libxml_disable_entity_loader) { RETURN_TRUE; }
4
hook_libxml_disable_entity_loader()5 int hook_libxml_disable_entity_loader() {
6 TSRMLS_FETCH();
7
8 // External entities are disabled by default in PHP8+
9 #if PHP_VERSION_ID < 80000
10 /* Call the php function here instead of re-implementing it is a bit
11 * ugly, but we do not want to introduce compile-time dependencies against
12 * libxml. */
13 zval func_name;
14 zval hmac;
15 zval params[1];
16
17 ZVAL_STRING(&func_name, "libxml_disable_entity_loader");
18 ZVAL_STRING(¶ms[0], "true");
19 call_user_function(CG(function_table), NULL, &func_name, &hmac, 1, params);
20 #endif
21
22 HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook,
23 PHP_FN(sp_libxml_disable_entity_loader));
24
25 return SUCCESS;
26 }
27