rrichards               Fri Jun 26 20:27:44 2009 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/libxml libxml.c 
  Log:
  MFH: add libxml_disable_entity_loader function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.32.2.7.2.19&r2=1.32.2.7.2.20&diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.32.2.7.2.19 
php-src/ext/libxml/libxml.c:1.32.2.7.2.20
--- php-src/ext/libxml/libxml.c:1.32.2.7.2.19   Tue Jun 23 12:38:32 2009
+++ php-src/ext/libxml/libxml.c Fri Jun 26 20:27:44 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: libxml.c,v 1.32.2.7.2.19 2009/06/23 12:38:32 bjori Exp $ */
+/* $Id: libxml.c,v 1.32.2.7.2.20 2009/06/26 20:27:44 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -68,6 +68,7 @@
 static PHP_FUNCTION(libxml_get_last_error);
 static PHP_FUNCTION(libxml_clear_errors);
 static PHP_FUNCTION(libxml_get_errors);
+static PHP_FUNCTION(libxml_disable_entity_loader);
 
 static zend_class_entry *libxmlerror_class_entry;
 
@@ -109,6 +110,11 @@
 ZEND_BEGIN_ARG_INFO(arginfo_libxml_clear_errors, 0)
 ZEND_END_ARG_INFO()
 
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_libxml_disable_entity_loader, 0, 0, 0)
+       ZEND_ARG_INFO(0, disable)
+ZEND_END_ARG_INFO()
+
 /* }}} */
 
 /* {{{ extension definition structures */
@@ -118,6 +124,7 @@
        PHP_FE(libxml_get_last_error, arginfo_libxml_get_last_error)
        PHP_FE(libxml_clear_errors, arginfo_libxml_clear_errors)
        PHP_FE(libxml_get_errors, arginfo_libxml_get_errors)
+       PHP_FE(libxml_disable_entity_loader, 
arginfo_libxml_disable_entity_loader)
        {NULL, NULL, NULL}
 };
 
@@ -349,6 +356,12 @@
 }
 
 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;
@@ -823,6 +836,31 @@
 }
 /* }}} */
 
+/* {{{ 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;
+}
+/* }}} */
+
 /* {{{ Common functions shared by extensions */
 int php_libxml_xmlCheckUTF8(const unsigned char *s)
 {



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

Reply via email to