diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-03-13 12:34:20 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-03-13 12:34:20 +0100 |
| commit | 92984f18f6aee9c0f719febb9fc09a0c50262c2f (patch) | |
| tree | 36d95d0aa548ede359a4da5338cf1162890ab524 /ext/libxml | |
| parent | 7ad1f708d5748e36de4b51088b377907e5ea01e7 (diff) | |
| download | php-92984f18f6aee9c0f719febb9fc09a0c50262c2f.tar.gz | |
Imported Upstream version 5.5.0~alpha6upstream/5.5.0_alpha6
Diffstat (limited to 'ext/libxml')
| -rw-r--r-- | ext/libxml/libxml.c | 33 | ||||
| -rw-r--r-- | ext/libxml/php_libxml.h | 2 |
2 files changed, 17 insertions, 18 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 0f1c2bb82..b1cb45db7 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -270,6 +270,7 @@ static PHP_GINIT_FUNCTION(libxml) libxml_globals->error_buffer.c = NULL; libxml_globals->error_list = NULL; libxml_globals->entity_loader.fci.size = 0; + libxml_globals->entity_loader_disabled = 0; } static void _php_libxml_destroy_fci(zend_fcall_info *fci) @@ -369,16 +370,15 @@ static int php_libxml_streams_IO_close(void *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); @@ -1052,28 +1052,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)); } /* }}} */ diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index 8b9acc044..04f8b4933 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -47,6 +47,7 @@ ZEND_BEGIN_MODULE_GLOBALS(libxml) zend_fcall_info fci; zend_fcall_info_cache fcc; } entity_loader; + zend_bool entity_loader_disabled; ZEND_END_MODULE_GLOBALS(libxml) typedef struct _libxml_doc_props { @@ -97,6 +98,7 @@ PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...); PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s); PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC); PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg TSRMLS_DC); +PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable TSRMLS_DC); /* Init/shutdown functions*/ PHP_LIBXML_API void php_libxml_initialize(void); |
