On Tue, 30 Aug 2011 14:11:28 +0100, Rob Richards <rricha...@php.net> wrote:

I don't have a computer right now to see what you wrote for this, but we
cannot use any of the global methods unless you have protection built in
to only execute if within the context of a PHP call. Easiest way to see
the conflict is by running both mod_php and mod_perl.


Yes, I feared this could became a problem but I couldn't conceive a relatively common scenario like the one you mentioned.

What do you think of the patch below?

Index: ext/libxml/libxml.c
===================================================================
--- ext/libxml/libxml.c (revision 315838)
+++ ext/libxml/libxml.c (working copy)
@@ -674,6 +674,18 @@
        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 @@
                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 @@
 #endif
                xmlCleanupParser();
                zend_hash_destroy(&php_libxml_exports);
+               
+               xmlSetExternalEntityLoader(_php_libxml_default_entity_loader);
                _php_libxml_initialized = 0;
        }
 }


--
Gustavo Lopes

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to