diff options
author | Dmitry Stogov <dmitry@zend.com> | 2013-02-20 22:27:41 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2013-02-20 22:27:41 +0400 |
commit | c737b89473df9dba6742b8fc8fbf6d009bf05c36 (patch) | |
tree | 5d067fae4757d65bd66f57bab59c1a0dec0dc56c /ext | |
parent | 021f57ef0e21868f6bbef34c4b1a1a2bf5461159 (diff) | |
parent | 8e76d0404b7f664ee6719fd98f0483f0ac4669d6 (diff) | |
download | php-git-c737b89473df9dba6742b8fc8fbf6d009bf05c36.tar.gz |
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
Fixed external entity loading
Conflicts:
ext/libxml/libxml.c
ext/libxml/php_libxml.h
Diffstat (limited to 'ext')
-rw-r--r-- | ext/libxml/libxml.c | 33 | ||||
-rw-r--r-- | ext/libxml/php_libxml.h | 2 | ||||
-rw-r--r-- | ext/soap/php_xml.c | 11 |
3 files changed, 26 insertions, 20 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 0f1c2bb825..b1cb45db76 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 8b9acc044e..04f8b4933b 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); diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index 737a335e3a..a74ec02f43 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -20,6 +20,7 @@ /* $Id$ */ #include "php_soap.h" +#include "ext/libxml/php_libxml.h" #include "libxml/parser.h" #include "libxml/parserInternals.h" @@ -91,14 +92,17 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC) ctxt = xmlCreateFileParserCtxt(filename); PG(allow_url_fopen) = old_allow_url_fopen; if (ctxt) { + zend_bool old; + ctxt->keepBlanks = 0; - ctxt->options &= ~XML_PARSE_DTDLOAD; ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; ctxt->sax->error = NULL; /*ctxt->sax->fatalError = NULL;*/ + old = php_libxml_disable_entity_loader(1); xmlParseDocument(ctxt); + php_libxml_disable_entity_loader(old); if (ctxt->wellFormed) { ret = ctxt->myDoc; if (ret->URL == NULL && ctxt->directory != NULL) { @@ -134,7 +138,8 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) */ ctxt = xmlCreateMemoryParserCtxt(buf, buf_size); if (ctxt) { - ctxt->options &= ~XML_PARSE_DTDLOAD; + zend_bool old; + ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; @@ -143,7 +148,9 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) #if LIBXML_VERSION >= 20703 ctxt->options |= XML_PARSE_HUGE; #endif + old = php_libxml_disable_entity_loader(1); xmlParseDocument(ctxt); + php_libxml_disable_entity_loader(old); if (ctxt->wellFormed) { ret = ctxt->myDoc; if (ret->URL == NULL && ctxt->directory != NULL) { |