summaryrefslogtreecommitdiff
path: root/ext/libxml
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2011-09-02 05:14:32 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2011-09-02 05:14:32 +0000
commitdc32339c3393139759084537ee930d2c3ec18bef (patch)
tree39ca6c6223d5dd55e89d431e4b810e6babf5c6a0 /ext/libxml
parent7c63e28708583879050c4779c0a9e23c49001387 (diff)
downloadphp-git-dc32339c3393139759084537ee930d2c3ec18bef.tar.gz
- Use our external entity loader only in the context of a PHP request.
Diffstat (limited to 'ext/libxml')
-rw-r--r--ext/libxml/libxml.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index f488b38f42..00f257c7dd 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -674,6 +674,18 @@ is_string:
return ret;
}
+static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL,
+ const char *ID, xmlParserCtxtPtr context)
+{
+ /* Check whether we're running in a PHP context, since the entity loader
+ * we've defined is an application level (true global) setting */
+ if (xmlGenericError == php_libxml_error_handler) {
+ return _php_libxml_external_entity_loader(URL, ID, context);
+ } else {
+ return _php_libxml_default_entity_loader(URL, ID, context);
+ }
+}
+
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...)
{
va_list args;
@@ -713,7 +725,7 @@ PHP_LIBXML_API void php_libxml_initialize(void)
xmlInitParser();
_php_libxml_default_entity_loader = xmlGetExternalEntityLoader();
- xmlSetExternalEntityLoader(_php_libxml_external_entity_loader);
+ xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader);
zend_hash_init(&php_libxml_exports, 0, NULL, NULL, 1);
@@ -729,6 +741,8 @@ PHP_LIBXML_API void php_libxml_shutdown(void)
#endif
xmlCleanupParser();
zend_hash_destroy(&php_libxml_exports);
+
+ xmlSetExternalEntityLoader(_php_libxml_default_entity_loader);
_php_libxml_initialized = 0;
}
}