|
|
| version 1.1.1.2, 2012/05/29 12:34:40 | version 1.1.1.3, 2013/07/22 01:31:52 |
|---|---|
| Line 2 | Line 2 |
| +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ |
| | PHP Version 5 | | | PHP Version 5 | |
| +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ |
| | Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
| +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ |
| | This source file is subject to version 3.01 of the PHP license, | | | This source file is subject to version 3.01 of the PHP license, | |
| | that is bundled with this package in the file LICENSE, and is | | | that is bundled with this package in the file LICENSE, and is | |
| Line 270 static PHP_GINIT_FUNCTION(libxml) | Line 270 static PHP_GINIT_FUNCTION(libxml) |
| libxml_globals->error_buffer.c = NULL; | libxml_globals->error_buffer.c = NULL; |
| libxml_globals->error_list = NULL; | libxml_globals->error_list = NULL; |
| libxml_globals->entity_loader.fci.size = 0; | libxml_globals->entity_loader.fci.size = 0; |
| libxml_globals->entity_loader_disabled = 0; | |
| } | } |
| static void _php_libxml_destroy_fci(zend_fcall_info *fci) | static void _php_libxml_destroy_fci(zend_fcall_info *fci) |
| Line 369 static int php_libxml_streams_IO_close(void *context) | Line 370 static int php_libxml_streams_IO_close(void *context) |
| } | } |
| static xmlParserInputBufferPtr | 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) | php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc) |
| { | { |
| xmlParserInputBufferPtr ret; | xmlParserInputBufferPtr ret; |
| void *context = NULL; | void *context = NULL; |
| TSRMLS_FETCH(); | |
| if (LIBXML(entity_loader_disabled)) { | |
| return NULL; | |
| } | |
| if (URI == NULL) | if (URI == NULL) |
| return(NULL); | return(NULL); |
| Line 677 is_string: | Line 677 is_string: |
| static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL, | static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL, |
| const char *ID, xmlParserCtxtPtr context) | const char *ID, xmlParserCtxtPtr context) |
| { | { |
| TSRMLS_FETCH(); | |
| /* Check whether we're running in a PHP context, since the entity loader | /* Check whether we're running in a PHP context, since the entity loader |
| * we've defined is an application level (true global) setting */ | * we've defined is an application level (true global) setting. |
| if (xmlGenericError == php_libxml_error_handler) { | * If we are, we also want to check whether we've finished activating |
| * the modules (RINIT phase). Using our external entity loader during a | |
| * RINIT should not be problem per se (though during MINIT it is, because | |
| * we don't even have a resource list by then), but then whether one | |
| * extension would be using the custom external entity loader or not | |
| * could depend on extension loading order | |
| * (if _php_libxml_per_request_initialization */ | |
| if (xmlGenericError == php_libxml_error_handler && PG(modules_activated)) { | |
| return _php_libxml_external_entity_loader(URL, ID, context); | return _php_libxml_external_entity_loader(URL, ID, context); |
| } else { | } else { |
| return _php_libxml_default_entity_loader(URL, ID, context); | return _php_libxml_default_entity_loader(URL, ID, context); |
| Line 851 static PHP_MSHUTDOWN_FUNCTION(libxml) | Line 860 static PHP_MSHUTDOWN_FUNCTION(libxml) |
| { | { |
| if (!_php_libxml_per_request_initialization) { | if (!_php_libxml_per_request_initialization) { |
| xmlSetGenericErrorFunc(NULL, NULL); | xmlSetGenericErrorFunc(NULL, NULL); |
| xmlSetStructuredErrorFunc(NULL, NULL); | |
| xmlParserInputBufferCreateFilenameDefault(NULL); | xmlParserInputBufferCreateFilenameDefault(NULL); |
| xmlOutputBufferCreateFilenameDefault(NULL); | xmlOutputBufferCreateFilenameDefault(NULL); |
| Line 867 static int php_libxml_post_deactivate() | Line 875 static int php_libxml_post_deactivate() |
| /* reset libxml generic error handling */ | /* reset libxml generic error handling */ |
| if (_php_libxml_per_request_initialization) { | if (_php_libxml_per_request_initialization) { |
| xmlSetGenericErrorFunc(NULL, NULL); | xmlSetGenericErrorFunc(NULL, NULL); |
| xmlSetStructuredErrorFunc(NULL, NULL); | |
| xmlParserInputBufferCreateFilenameDefault(NULL); | xmlParserInputBufferCreateFilenameDefault(NULL); |
| xmlOutputBufferCreateFilenameDefault(NULL); | xmlOutputBufferCreateFilenameDefault(NULL); |
| } | } |
| xmlSetStructuredErrorFunc(NULL, NULL); | |
| if (LIBXML(stream_context)) { | if (LIBXML(stream_context)) { |
| zval_ptr_dtor(&LIBXML(stream_context)); | /* the steam_context resource will be released by resource list destructor */ |
| efree(LIBXML(stream_context)); | |
| LIBXML(stream_context) = NULL; | LIBXML(stream_context) = NULL; |
| } | } |
| smart_str_free(&LIBXML(error_buffer)); | smart_str_free(&LIBXML(error_buffer)); |
| Line 908 static PHP_FUNCTION(libxml_set_streams_context) | Line 917 static PHP_FUNCTION(libxml_set_streams_context) |
| { | { |
| zval *arg; | zval *arg; |
| if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg) == FAILURE) { |
| return; | return; |
| } | } |
| if (LIBXML(stream_context)) { | if (LIBXML(stream_context)) { |
| Line 1043 static PHP_FUNCTION(libxml_clear_errors) | Line 1052 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]) | /* {{{ proto bool libxml_disable_entity_loader([boolean disable]) |
| Disable/Enable ability to load external entities */ | Disable/Enable ability to load external entities */ |
| static PHP_FUNCTION(libxml_disable_entity_loader) | static PHP_FUNCTION(libxml_disable_entity_loader) |
| { | { |
| zend_bool disable = 1; | zend_bool disable = 1; |
| xmlParserInputBufferCreateFilenameFunc old; | |
| if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &disable) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &disable) == FAILURE) { |
| return; | return; |
| } | } |
| if (disable == 0) { | RETURN_BOOL(php_libxml_disable_entity_loader(disable TSRMLS_CC)); |
| 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; | |
| } | } |
| /* }}} */ | /* }}} */ |