|
|
|
@ -261,6 +261,7 @@ static PHP_GINIT_FUNCTION(libxml) |
|
|
|
libxml_globals->stream_context = NULL; |
|
|
|
libxml_globals->error_buffer.c = NULL; |
|
|
|
libxml_globals->error_list = NULL; |
|
|
|
libxml_globals->entity_loader_disabled = 0; |
|
|
|
} |
|
|
|
|
|
|
|
/* Channel libxml file io layer through the PHP streams subsystem. |
|
|
|
@ -347,17 +348,16 @@ static int php_libxml_streams_IO_close(void *context) |
|
|
|
return php_stream_close((php_stream*)context); |
|
|
|
} |
|
|
|
|
|
|
|
static xmlParserInputBufferPtr |
|
|
|
php_libxml_input_buffer_noload(const char *URI, xmlCharEncoding enc) |
|
|
|
{ |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
static xmlParserInputBufferPtr |
|
|
|
php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc) |
|
|
|
{ |
|
|
|
xmlParserInputBufferPtr ret; |
|
|
|
void *context = NULL; |
|
|
|
TSRMLS_FETCH(); |
|
|
|
|
|
|
|
if (LIBXML(entity_loader_disabled)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
if (URI == NULL) |
|
|
|
return(NULL); |
|
|
|
@ -834,28 +834,25 @@ static PHP_FUNCTION(libxml_clear_errors) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable TSRMLS_DC) |
|
|
|
{ |
|
|
|
zend_bool old = LIBXML(entity_loader_disabled); |
|
|
|
|
|
|
|
LIBXML(entity_loader_disabled) = disable; |
|
|
|
return old; |
|
|
|
} |
|
|
|
|
|
|
|
/* {{{ proto bool libxml_disable_entity_loader([boolean disable]) |
|
|
|
Disable/Enable ability to load external entities */ |
|
|
|
static PHP_FUNCTION(libxml_disable_entity_loader) |
|
|
|
{ |
|
|
|
zend_bool disable = 1; |
|
|
|
xmlParserInputBufferCreateFilenameFunc old; |
|
|
|
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &disable) == FAILURE) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (disable == 0) { |
|
|
|
old = xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_create_filename); |
|
|
|
} else { |
|
|
|
old = xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_noload); |
|
|
|
} |
|
|
|
|
|
|
|
if (old == php_libxml_input_buffer_noload) { |
|
|
|
RETURN_TRUE; |
|
|
|
} |
|
|
|
|
|
|
|
RETURN_FALSE; |
|
|
|
RETURN_BOOL(php_libxml_disable_entity_loader(disable TSRMLS_CC)); |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
|