@@ -261,6 +261,7 @@ static PHP_GINIT_FUNCTION(libxml)
261
261
libxml_globals -> stream_context = NULL ;
262
262
libxml_globals -> error_buffer .c = NULL ;
263
263
libxml_globals -> error_list = NULL ;
264
+ libxml_globals -> entity_loader_disabled = 0 ;
264
265
}
265
266
266
267
/* Channel libxml file io layer through the PHP streams subsystem.
@@ -347,17 +348,16 @@ static int php_libxml_streams_IO_close(void *context)
347
348
return php_stream_close ((php_stream * )context );
348
349
}
349
350
350
- static xmlParserInputBufferPtr
351
- php_libxml_input_buffer_noload (const char * URI , xmlCharEncoding enc )
352
- {
353
- return NULL ;
354
- }
355
-
356
351
static xmlParserInputBufferPtr
357
352
php_libxml_input_buffer_create_filename (const char * URI , xmlCharEncoding enc )
358
353
{
359
354
xmlParserInputBufferPtr ret ;
360
355
void * context = NULL ;
356
+ TSRMLS_FETCH ();
357
+
358
+ if (LIBXML (entity_loader_disabled )) {
359
+ return NULL ;
360
+ }
361
361
362
362
if (URI == NULL )
363
363
return (NULL );
@@ -834,28 +834,25 @@ static PHP_FUNCTION(libxml_clear_errors)
834
834
}
835
835
/* }}} */
836
836
837
+ PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader (zend_bool disable TSRMLS_DC )
838
+ {
839
+ zend_bool old = LIBXML (entity_loader_disabled );
840
+
841
+ LIBXML (entity_loader_disabled ) = disable ;
842
+ return old ;
843
+ }
844
+
837
845
/* {{{ proto bool libxml_disable_entity_loader([boolean disable])
838
846
Disable/Enable ability to load external entities */
839
847
static PHP_FUNCTION (libxml_disable_entity_loader )
840
848
{
841
849
zend_bool disable = 1 ;
842
- xmlParserInputBufferCreateFilenameFunc old ;
843
850
844
851
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|b" , & disable ) == FAILURE ) {
845
852
return ;
846
853
}
847
854
848
- if (disable == 0 ) {
849
- old = xmlParserInputBufferCreateFilenameDefault (php_libxml_input_buffer_create_filename );
850
- } else {
851
- old = xmlParserInputBufferCreateFilenameDefault (php_libxml_input_buffer_noload );
852
- }
853
-
854
- if (old == php_libxml_input_buffer_noload ) {
855
- RETURN_TRUE ;
856
- }
857
-
858
- RETURN_FALSE ;
855
+ RETURN_BOOL (php_libxml_disable_entity_loader (disable TSRMLS_CC ));
859
856
}
860
857
/* }}} */
861
858
0 commit comments