@@ -270,6 +270,7 @@ static PHP_GINIT_FUNCTION(libxml)
270
270
libxml_globals -> error_buffer .c = NULL ;
271
271
libxml_globals -> error_list = NULL ;
272
272
libxml_globals -> entity_loader .fci .size = 0 ;
273
+ libxml_globals -> entity_loader_disabled = 0 ;
273
274
}
274
275
275
276
static void _php_libxml_destroy_fci (zend_fcall_info * fci )
@@ -368,17 +369,16 @@ static int php_libxml_streams_IO_close(void *context)
368
369
return php_stream_close ((php_stream * )context );
369
370
}
370
371
371
- static xmlParserInputBufferPtr
372
- php_libxml_input_buffer_noload (const char * URI , xmlCharEncoding enc )
373
- {
374
- return NULL ;
375
- }
376
-
377
372
static xmlParserInputBufferPtr
378
373
php_libxml_input_buffer_create_filename (const char * URI , xmlCharEncoding enc )
379
374
{
380
375
xmlParserInputBufferPtr ret ;
381
376
void * context = NULL ;
377
+ TSRMLS_FETCH ();
378
+
379
+ if (LIBXML (entity_loader_disabled )) {
380
+ return NULL ;
381
+ }
382
382
383
383
if (URI == NULL )
384
384
return (NULL );
@@ -1052,28 +1052,25 @@ static PHP_FUNCTION(libxml_clear_errors)
1052
1052
}
1053
1053
/* }}} */
1054
1054
1055
+ PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader (zend_bool disable TSRMLS_DC )
1056
+ {
1057
+ zend_bool old = LIBXML (entity_loader_disabled );
1058
+
1059
+ LIBXML (entity_loader_disabled ) = disable ;
1060
+ return old ;
1061
+ }
1062
+
1055
1063
/* {{{ proto bool libxml_disable_entity_loader([boolean disable])
1056
1064
Disable/Enable ability to load external entities */
1057
1065
static PHP_FUNCTION (libxml_disable_entity_loader )
1058
1066
{
1059
1067
zend_bool disable = 1 ;
1060
- xmlParserInputBufferCreateFilenameFunc old ;
1061
1068
1062
1069
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|b" , & disable ) == FAILURE ) {
1063
1070
return ;
1064
1071
}
1065
1072
1066
- if (disable == 0 ) {
1067
- old = xmlParserInputBufferCreateFilenameDefault (php_libxml_input_buffer_create_filename );
1068
- } else {
1069
- old = xmlParserInputBufferCreateFilenameDefault (php_libxml_input_buffer_noload );
1070
- }
1071
-
1072
- if (old == php_libxml_input_buffer_noload ) {
1073
- RETURN_TRUE ;
1074
- }
1075
-
1076
- RETURN_FALSE ;
1073
+ RETURN_BOOL (php_libxml_disable_entity_loader (disable TSRMLS_CC ));
1077
1074
}
1078
1075
/* }}} */
1079
1076
0 commit comments