[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2009-06-23 Thread Rob Richards
rrichards   Tue Jun 23 10:49:01 2009 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  add libxml_disable_entity_loader function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.77r2=1.78diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.77 php-src/ext/libxml/libxml.c:1.78
--- php-src/ext/libxml/libxml.c:1.77Thu Mar 26 22:16:48 2009
+++ php-src/ext/libxml/libxml.c Tue Jun 23 10:49:00 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.77 2009/03/26 22:16:48 felipe Exp $ */
+/* $Id: libxml.c,v 1.78 2009/06/23 10:49:00 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;
 
@@ -104,6 +105,10 @@
 ZEND_BEGIN_ARG_INFO(arginfo_libxml_clear_errors, 0)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO(arginfo_libxml_disable_entity_loader, 0)
+   ZEND_ARG_INFO(0, disable)
+ZEND_END_ARG_INFO()
+
 /* }}} */
 
 /* {{{ extension definition structures */
@@ -113,6 +118,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}
 };
 
@@ -344,6 +350,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;
@@ -820,6 +832,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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2009-06-23 Thread Hannes Magnusson
bjori   Tue Jun 23 12:27:36 2009 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fix arginfo for libxml_disable_entity_loader() and
  libxml_use_internal_errors()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.78r2=1.79diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.78 php-src/ext/libxml/libxml.c:1.79
--- php-src/ext/libxml/libxml.c:1.78Tue Jun 23 10:49:00 2009
+++ php-src/ext/libxml/libxml.c Tue Jun 23 12:27:36 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.78 2009/06/23 10:49:00 rrichards Exp $ */
+/* $Id: libxml.c,v 1.79 2009/06/23 12:27:36 bjori Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -92,7 +92,7 @@
ZEND_ARG_INFO(0, context)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO(arginfo_libxml_use_internal_errors, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_libxml_use_internal_errors, 0, 0, 0)
ZEND_ARG_INFO(0, use_errors)
 ZEND_END_ARG_INFO()
 
@@ -105,7 +105,7 @@
 ZEND_BEGIN_ARG_INFO(arginfo_libxml_clear_errors, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO(arginfo_libxml_disable_entity_loader, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_libxml_disable_entity_loader, 0, 0, 0)
ZEND_ARG_INFO(0, disable)
 ZEND_END_ARG_INFO()
 



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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2009-03-13 Thread Rob Richards
rrichards   Fri Mar 13 19:35:14 2009 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  add LIBXML_LOADED_VERSION constant that contains currently loaded libxml2 
version
  add libxml2 version being used to info output
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.74r2=1.75diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.74 php-src/ext/libxml/libxml.c:1.75
--- php-src/ext/libxml/libxml.c:1.74Tue Mar 10 23:39:27 2009
+++ php-src/ext/libxml/libxml.c Fri Mar 13 19:35:14 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.74 2009/03/10 23:39:27 helly Exp $ */
+/* $Id: libxml.c,v 1.75 2009/03/13 19:35:14 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -592,6 +592,7 @@
 
REGISTER_LONG_CONSTANT(LIBXML_VERSION,
LIBXML_VERSION, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT(LIBXML_DOTTED_VERSION,   
LIBXML_DOTTED_VERSION,  CONST_CS | CONST_PERSISTENT);
+   REGISTER_STRING_CONSTANT(LIBXML_LOADED_VERSION,   (char 
*)xmlParserVersion,   CONST_CS | CONST_PERSISTENT);
 
/* For use with loading xml */
REGISTER_LONG_CONSTANT(LIBXML_NOENT,  XML_PARSE_NOENT,
CONST_CS | CONST_PERSISTENT);
@@ -671,7 +672,8 @@
 {
php_info_print_table_start();
php_info_print_table_row(2, libXML support, active);
-   php_info_print_table_row(2, libXML Version, LIBXML_DOTTED_VERSION);
+   php_info_print_table_row(2, libXML Compiled Version, 
LIBXML_DOTTED_VERSION);
+   php_info_print_table_row(2, libXML Loaded Version, (char 
*)xmlParserVersion);
php_info_print_table_row(2, libXML streams, enabled);
php_info_print_table_end();
 }



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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2008-07-22 Thread Rob Richards
rrichards   Tue Jul 22 10:29:14 2008 UTC

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  - Visibility (bug #45557)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.68r2=1.69diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.68 php-src/ext/libxml/libxml.c:1.69
--- php-src/ext/libxml/libxml.c:1.68Mon Jul 21 09:36:41 2008
+++ php-src/ext/libxml/libxml.c Tue Jul 22 10:29:14 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.68 2008/07/21 09:36:41 bjori Exp $ */
+/* $Id: libxml.c,v 1.69 2008/07/22 10:29:14 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -523,7 +523,7 @@
}
 }
 
-void php_libxml_ctx_error(void *ctx, const char *msg, ...)
+PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...)
 {
va_list args;
va_start(args, msg);
@@ -531,7 +531,7 @@
va_end(args);
 }
 
-void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
+PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
 {
va_list args;
va_start(args, msg);
@@ -993,7 +993,7 @@
return ret_refcount;
 }
 
-void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC)
+PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC)
 {
if (!node) {
return;
@@ -1029,7 +1029,7 @@
}
 }
 
-void php_libxml_node_decrement_resource(php_libxml_node_object *object 
TSRMLS_DC)
+PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object 
*object TSRMLS_DC)
 {
int ret_refcount = -1;
xmlNodePtr nodep;
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/php_libxml.h?r1=1.29r2=1.30diff_format=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.29 
php-src/ext/libxml/php_libxml.h:1.30
--- php-src/ext/libxml/php_libxml.h:1.29Wed Jan 30 09:56:21 2008
+++ php-src/ext/libxml/php_libxml.h Tue Jul 22 10:29:14 2008
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.29 2008/01/30 09:56:21 dmitry Exp $ */
+/* $Id: php_libxml.h,v 1.30 2008/07/22 10:29:14 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -86,12 +86,12 @@
 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);
 PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, 
php_libxml_export_node export_function);
 /* When an explicit freeing of node and children is required */
-void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
+PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
 /* When object dtor is called as node may still be referenced */
-void php_libxml_node_decrement_resource(php_libxml_node_object *object 
TSRMLS_DC);
+PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object 
*object TSRMLS_DC);
 PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
-void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
-void php_libxml_ctx_error(void *ctx, const char *msg, ...);
+PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
+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 CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2008-07-21 Thread Hannes Magnusson
bjori   Mon Jul 21 09:36:41 2008 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fix proto
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.67r2=1.68diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.67 php-src/ext/libxml/libxml.c:1.68
--- php-src/ext/libxml/libxml.c:1.67Wed Jan 30 15:28:09 2008
+++ php-src/ext/libxml/libxml.c Mon Jul 21 09:36:41 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.67 2008/01/30 15:28:09 rrichards Exp $ */
+/* $Id: libxml.c,v 1.68 2008/07/21 09:36:41 bjori Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -700,7 +700,7 @@
 }
 /* }}} */
 
-/* {{{ proto void libxml_use_internal_errors([boolean use_errors]) U
+/* {{{ proto bool libxml_use_internal_errors([boolean use_errors]) U
Disable libxml errors and allow user to fetch error information as needed */
 static PHP_FUNCTION(libxml_use_internal_errors)
 {



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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2008-01-30 Thread Rob Richards
rrichards   Wed Jan 30 15:28:10 2008 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  fix bug #41562 (SimpleXML memory issue)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.66r2=1.67diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.66 php-src/ext/libxml/libxml.c:1.67
--- php-src/ext/libxml/libxml.c:1.66Mon Dec 31 07:12:11 2007
+++ php-src/ext/libxml/libxml.c Wed Jan 30 15:28:09 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.66 2007/12/31 07:12:11 sebastian Exp $ */
+/* $Id: libxml.c,v 1.67 2008/01/30 15:28:09 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -141,24 +141,6 @@
 /* }}} */
 
 /* {{{ internal functions for interoperability */
-static int php_libxml_dec_node(php_libxml_node_ptr *nodeptr)
-{
-   int ret_refcount;
-
-   ret_refcount = --nodeptr-refcount;
-   if (ret_refcount == 0) {
-   if (nodeptr-node != NULL  nodeptr-node-type != 
XML_DOCUMENT_NODE) {
-   nodeptr-node-_private = NULL;
-   }
-   /* node is destroyed by another object. reset ret_refcount to 1 
and node to NULL
-   so the php_libxml_node_ptr is detroyed when the object is 
destroyed */
-   nodeptr-refcount = 1;
-   nodeptr-node = NULL;
-   }
-
-   return ret_refcount;
-}
-
 static int php_libxml_clear_object(php_libxml_node_object *object TSRMLS_DC)
 {
if (object-properties) {
@@ -179,7 +161,10 @@
if (wrapper) {
php_libxml_clear_object(wrapper TSRMLS_CC);
} else {
-   php_libxml_dec_node(nodeptr);
+   if (nodeptr-node != NULL  nodeptr-node-type != 
XML_DOCUMENT_NODE) {
+   nodeptr-node-_private = NULL;
+   }
+   nodeptr-node = NULL;
}
}
 

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2007-08-01 Thread Antony Dovgal
tony2001Wed Aug  1 11:43:27 2007 UTC

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  an attempt to fix win32 build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.62r2=1.63diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.62 php-src/ext/libxml/libxml.c:1.63
--- php-src/ext/libxml/libxml.c:1.62Sat Jul 28 08:34:09 2007
+++ php-src/ext/libxml/libxml.c Wed Aug  1 11:43:27 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.62 2007/07/28 08:34:09 rrichards Exp $ */
+/* $Id: libxml.c,v 1.63 2007/08/01 11:43:27 tony2001 Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -897,7 +897,7 @@
 
 }
 
-int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr 
node, void *private_data TSRMLS_DC)
+PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object 
*object, xmlNodePtr node, void *private_data TSRMLS_DC)
 {
int ret_refcount = -1;
 
@@ -929,7 +929,7 @@
return ret_refcount;
 }
 
-int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC)
+PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object 
*object TSRMLS_DC)
 {
int ret_refcount = -1;
php_libxml_node_ptr *obj_node;
@@ -949,7 +949,7 @@
return ret_refcount;
 }
 
-int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr 
docp TSRMLS_DC)
+PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object 
*object, xmlDocPtr docp TSRMLS_DC)
 {
int ret_refcount = -1;
 
@@ -969,7 +969,7 @@
return ret_refcount;
 }
 
-int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC)
+PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object 
TSRMLS_DC)
 {
int ret_refcount = -1;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/php_libxml.h?r1=1.26r2=1.27diff_format=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.26 
php-src/ext/libxml/php_libxml.h:1.27
--- php-src/ext/libxml/php_libxml.h:1.26Sat Jul 21 00:49:53 2007
+++ php-src/ext/libxml/php_libxml.h Wed Aug  1 11:43:27 2007
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.26 2007/07/21 00:49:53 jani Exp $ */
+/* $Id: php_libxml.h,v 1.27 2007/08/01 11:43:27 tony2001 Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -77,8 +77,8 @@
 
 typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
 
-int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr 
node, void *private_data TSRMLS_DC);
-int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
+PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object 
*object, xmlNodePtr node, void *private_data TSRMLS_DC);
+PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object 
*object TSRMLS_DC);
 PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object 
*object, xmlDocPtr docp TSRMLS_DC);
 PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object 
TSRMLS_DC);
 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c /ext/libxml/tests bug42112.phpt

2007-07-28 Thread Rob Richards
rrichards   Sat Jul 28 08:34:10 2007 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
/php-src/ext/libxml/tests   bug42112.phpt 
  Log:
  MFB: Fixed Bug #42112 (deleting a node produces memory corruption)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.61r2=1.62diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.61 php-src/ext/libxml/libxml.c:1.62
--- php-src/ext/libxml/libxml.c:1.61Sat Jul 21 00:49:53 2007
+++ php-src/ext/libxml/libxml.c Sat Jul 28 08:34:09 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.61 2007/07/21 00:49:53 jani Exp $ */
+/* $Id: libxml.c,v 1.62 2007/07/28 08:34:09 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -240,11 +240,14 @@
case XML_ENTITY_REF_NODE:
php_libxml_node_free_list((xmlNodePtr) 
node-properties TSRMLS_CC);
break;
+   case XML_ATTRIBUTE_NODE:
+   if ((node-doc != NULL)  
(((xmlAttrPtr) node)-atype == XML_ATTRIBUTE_ID)) {
+   xmlRemoveID(node-doc, 
(xmlAttrPtr) node);
+   }
case XML_ATTRIBUTE_DECL:
case XML_DTD_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_ENTITY_DECL:
-   case XML_ATTRIBUTE_NODE:
case XML_NAMESPACE_DECL:
case XML_TEXT_NODE:

php_libxml_node_free_list(node-children TSRMLS_CC);
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/tests/bug42112.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/libxml/tests/bug42112.phpt
diff -u /dev/null php-src/ext/libxml/tests/bug42112.phpt:1.2
--- /dev/null   Sat Jul 28 08:34:10 2007
+++ php-src/ext/libxml/tests/bug42112.phpt  Sat Jul 28 08:34:09 2007
@@ -0,0 +1,31 @@
+--TEST--
+Bug #42112 (deleting a node produces memory corruption)
+--SKIPIF--
+?php if (!extension_loaded('dom')) die('skip'); ?
+--FILE--
+?php
+$xml = EOXML
+rootchild xml:id=id1baz/child/root
+EOXML;
+
+function remove_node($doc) {
+$node = $doc-getElementById( 'id1' );
+print 'Deleting Node: '.$node-nodeName.\n;
+$node-parentNode-removeChild( $node );
+}
+
+$doc = new DOMDocument();
+$doc-loadXML($xml);
+
+remove_node($doc);
+
+$node = $doc-getElementById( 'id1' );
+if ($node) {
+   print 'Found Node: '.$node-nodeName.\n;
+}
+$root = $doc-documentElement;
+print 'Root Node: '.$root-nodeName.\n;
+?
+--EXPECT--
+Deleting Node: child
+Root Node: root

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2007-07-20 Thread Jani Taskinen
janiSat Jul 21 00:49:53 2007 UTC

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  - ws + compile warning fixes
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.60r2=1.61diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.60 php-src/ext/libxml/libxml.c:1.61
--- php-src/ext/libxml/libxml.c:1.60Fri Jun 29 13:58:33 2007
+++ php-src/ext/libxml/libxml.c Sat Jul 21 00:49:53 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.60 2007/06/29 13:58:33 dmitry Exp $ */
+/* $Id: libxml.c,v 1.61 2007/07/21 00:49:53 jani Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -122,7 +122,7 @@
 };
 
 zend_module_entry libxml_module_entry = {
-STANDARD_MODULE_HEADER,
+   STANDARD_MODULE_HEADER,
libxml,/* extension name */
libxml_functions,/* extension function list */
PHP_MINIT(libxml),   /* extension-wide startup function */
@@ -130,11 +130,11 @@
PHP_RINIT(libxml),   /* per-request startup function */
PHP_RSHUTDOWN(libxml),   /* per-request shutdown function */
PHP_MINFO(libxml),   /* information function */
-NO_VERSION_YET,
-PHP_MODULE_GLOBALS(libxml), /* globals descriptor */
-PHP_GINIT(libxml),  /* globals ctor */
-NULL,   /* globals dtor */
-NULL,   /* post deactivate */
+   NO_VERSION_YET,
+   PHP_MODULE_GLOBALS(libxml), /* globals descriptor */
+   PHP_GINIT(libxml),  /* globals ctor */
+   NULL,   /* globals dtor */
+   NULL,   /* post deactivate */
STANDARD_MODULE_PROPERTIES_EX
 };
 
@@ -363,10 +363,10 @@
 static xmlParserInputBufferPtr
 php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
 {
-xmlParserInputBufferPtr ret;
-void *context = NULL;
+   xmlParserInputBufferPtr ret;
+   void *context = NULL;
 
-if (URI == NULL)
+   if (URI == NULL)
return(NULL);
 
context = php_libxml_streams_IO_open_read_wrapper(URI);
@@ -392,10 +392,10 @@
   xmlCharEncodingHandlerPtr encoder,
   int compression ATTRIBUTE_UNUSED)
 {
-xmlOutputBufferPtr ret;
-xmlURIPtr puri;
-void *context = NULL;
-char *unescaped = NULL;
+   xmlOutputBufferPtr ret;
+   xmlURIPtr puri;
+   void *context = NULL;
+   char *unescaped = NULL;
 
if (URI == NULL)
return(NULL);
@@ -432,7 +432,8 @@
return(ret);
 }
 
-static int _php_libxml_free_error(xmlErrorPtr error) {
+static int _php_libxml_free_error(xmlErrorPtr error)
+{
/* This will free the libxml alloc'd memory */
xmlResetError(error);
return 1;
@@ -566,7 +567,8 @@
 }
 
 
-PHP_LIBXML_API void php_libxml_initialize() {
+PHP_LIBXML_API void php_libxml_initialize(void)
+{
if (!_php_libxml_initialized) {
/* we should be the only one's to ever init!! */
xmlInitParser();
@@ -577,7 +579,8 @@
}
 }
 
-PHP_LIBXML_API void php_libxml_shutdown() {
+PHP_LIBXML_API void php_libxml_shutdown(void) 
+{
if (_php_libxml_initialized) {
 #if defined(LIBXML_SCHEMAS_ENABLED)
xmlRelaxNGCleanupTypes();
@@ -588,7 +591,8 @@
}
 }
 
-PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC) {
+PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC)
+{
zval *oldcontext;
 
oldcontext = LIBXML(stream_context);
@@ -643,7 +647,7 @@
xmlSetGenericErrorFunc(NULL, php_libxml_error_handler);

xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_create_filename);

xmlOutputBufferCreateFilenameDefault(php_libxml_output_buffer_create_filename);
-return SUCCESS;
+   return SUCCESS;
 }
 
 
@@ -821,7 +825,7 @@
 /* }}} */
 
 /* {{{ proto void libxml_clear_errors() U
-Clear last error from libxml */
+   Clear last error from libxml */
 static PHP_FUNCTION(libxml_clear_errors)
 {
xmlResetLastError();
@@ -922,7 +926,8 @@
return ret_refcount;
 }
 
-int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC) {
+int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC)
+{
int ret_refcount = -1;
php_libxml_node_ptr *obj_node;
 
@@ -941,7 +946,8 @@
return ret_refcount;
 }
 
-int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr 
docp TSRMLS_DC) {
+int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr 
docp TSRMLS_DC)
+{
int ret_refcount = -1;
 
if (object-document != NULL) {
@@ -960,7 +966,8 @@
return ret_refcount;
 }
 
-int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC) {
+int 

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2007-02-23 Thread Rob Richards
rrichards   Fri Feb 23 11:13:42 2007 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  fix bug #40598 (libxml segfault)
  mark more functions unicode safe
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.57r2=1.58diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.57 php-src/ext/libxml/libxml.c:1.58
--- php-src/ext/libxml/libxml.c:1.57Mon Jan  8 20:01:23 2007
+++ php-src/ext/libxml/libxml.c Fri Feb 23 11:13:42 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.57 2007/01/08 20:01:23 pollita Exp $ */
+/* $Id: libxml.c,v 1.58 2007/02/23 11:13:42 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -246,6 +246,7 @@
case XML_ENTITY_DECL:
case XML_ATTRIBUTE_NODE:
case XML_NAMESPACE_DECL:
+   case XML_TEXT_NODE:

php_libxml_node_free_list(node-children TSRMLS_CC);
break;
default:
@@ -688,7 +689,7 @@
 }
 /* }}} */
 
-/* {{{ proto void libxml_set_streams_context(resource streams_context) 
+/* {{{ proto void libxml_set_streams_context(resource streams_context) U
Set the streams context for the next libxml document load or write */
 static PHP_FUNCTION(libxml_set_streams_context)
 {
@@ -706,7 +707,7 @@
 }
 /* }}} */
 
-/* {{{ proto void libxml_use_internal_errors([boolean use_errors]) 
+/* {{{ proto void libxml_use_internal_errors([boolean use_errors]) U
Disable libxml errors and allow user to fetch error information as needed */
 static PHP_FUNCTION(libxml_use_internal_errors)
 {
@@ -746,7 +747,7 @@
 }
 /* }}} */
 
-/* {{{ proto object libxml_get_last_error() 
+/* {{{ proto object libxml_get_last_error()
Retrieve last error from libxml */
 static PHP_FUNCTION(libxml_get_last_error)
 {
@@ -818,7 +819,7 @@
 }
 /* }}} */
 
-/* {{{ proto void libxml_clear_errors() 
+/* {{{ proto void libxml_clear_errors() U
 Clear last error from libxml */
 static PHP_FUNCTION(libxml_clear_errors)
 {
@@ -1017,6 +1018,7 @@
case XML_ENTITY_DECL:
case XML_ATTRIBUTE_NODE:
case XML_NAMESPACE_DECL:
+   case XML_TEXT_NODE:
break;
default:

php_libxml_node_free_list((xmlNodePtr) node-properties TSRMLS_CC);

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2007-01-08 Thread Sara Golemon
pollita Mon Jan  8 20:01:23 2007 UTC

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  Allow libxml DomNodes to remain persistent when requested by other extensions
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.56r2=1.57diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.56 php-src/ext/libxml/libxml.c:1.57
--- php-src/ext/libxml/libxml.c:1.56Mon Jan  1 09:29:25 2007
+++ php-src/ext/libxml/libxml.c Mon Jan  8 20:01:23 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.56 2007/01/01 09:29:25 sebastian Exp $ */
+/* $Id: libxml.c,v 1.57 2007/01/08 20:01:23 pollita Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -947,7 +947,9 @@
ret_refcount = object-document-refcount;
} else if (docp != NULL) {
ret_refcount = 1;
-   object-document = emalloc(sizeof(php_libxml_ref_obj));
+   object-document = pemalloc(sizeof(php_libxml_ref_obj), 0);
+   object-document-persistent = 0;
+   object-document-external_owner = 0;
object-document-ptr = docp;
object-document-refcount = ret_refcount;
object-document-doc_props = NULL;
@@ -972,9 +974,23 @@
}
efree(object-document-doc_props);
}
-   efree(object-document);
+   pefree(object-document, object-document-persistent);
object-document = NULL;
-   }
+   } else if (ret_refcount == 1  
object-document-external_owner) {
+   /* PHP is done with this object, but someone else owns 
the DomNodes,
+* Kill the non-persistent bits, but leave the 
persistable php_libxml_ref_obj around */
+   if (object-document-doc_props != NULL) {
+   if (object-document-doc_props-classmap) {
+   
zend_hash_destroy(object-document-doc_props-classmap);
+   
FREE_HASHTABLE(object-document-doc_props-classmap);
+   }
+   efree(object-document-doc_props);
+   object-document-doc_props = NULL;
+   }
+   /* Don't worry about the fact that this memory is left 
unfreed,
+* Whoever else owns it has the pointer stored 
somewhere */
+   object-document = NULL;
+   }   
}
 
return ret_refcount;
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/php_libxml.h?r1=1.23r2=1.24diff_format=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.23 
php-src/ext/libxml/php_libxml.h:1.24
--- php-src/ext/libxml/php_libxml.h:1.23Mon Jan  1 09:29:25 2007
+++ php-src/ext/libxml/php_libxml.h Mon Jan  8 20:01:23 2007
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.23 2007/01/01 09:29:25 sebastian Exp $ */
+/* $Id: php_libxml.h,v 1.24 2007/01/08 20:01:23 pollita Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -58,6 +58,8 @@
void *ptr;
int   refcount;
libxml_doc_props *doc_props;
+   zend_bool persistent;
+   zend_bool external_owner;
 } php_libxml_ref_obj;
 
 typedef struct _php_libxml_node_ptr {

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2006-11-10 Thread Nuno Lopes
nlopess Fri Nov 10 18:05:58 2006 UTC

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.53r2=1.54diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.53 php-src/ext/libxml/libxml.c:1.54
--- php-src/ext/libxml/libxml.c:1.53Wed Sep  6 21:48:57 2006
+++ php-src/ext/libxml/libxml.c Fri Nov 10 18:05:58 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.53 2006/09/06 21:48:57 edink Exp $ */
+/* $Id: libxml.c,v 1.54 2006/11/10 18:05:58 nlopess Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -52,7 +52,7 @@
 #define PHP_LIBXML_CTX_WARNING 2
 
 /* a true global for initialization */
-int _php_libxml_initialized = 0;
+static int _php_libxml_initialized = 0;
 
 typedef struct _php_libxml_func_handler {
php_libxml_export_node export_func;
@@ -60,10 +60,16 @@
 
 static HashTable php_libxml_exports;
 
-ZEND_DECLARE_MODULE_GLOBALS(libxml)
+static ZEND_DECLARE_MODULE_GLOBALS(libxml)
 static PHP_GINIT_FUNCTION(libxml);
 
-zend_class_entry *libxmlerror_class_entry;
+static PHP_FUNCTION(libxml_set_streams_context);
+static PHP_FUNCTION(libxml_use_internal_errors);
+static PHP_FUNCTION(libxml_get_last_error);
+static PHP_FUNCTION(libxml_clear_errors);
+static PHP_FUNCTION(libxml_get_errors);
+
+static zend_class_entry *libxmlerror_class_entry;
 
 /* {{{ dynamically loadable module stuff */
 #ifdef COMPILE_DL_LIBXML
@@ -72,11 +78,11 @@
 /* }}} */
 
 /* {{{ function prototypes */
-PHP_MINIT_FUNCTION(libxml);
-PHP_RINIT_FUNCTION(libxml);
-PHP_MSHUTDOWN_FUNCTION(libxml);
-PHP_RSHUTDOWN_FUNCTION(libxml);
-PHP_MINFO_FUNCTION(libxml);
+static PHP_MINIT_FUNCTION(libxml);
+static PHP_RINIT_FUNCTION(libxml);
+static PHP_MSHUTDOWN_FUNCTION(libxml);
+static PHP_RSHUTDOWN_FUNCTION(libxml);
+static PHP_MINFO_FUNCTION(libxml);
 
 /* }}} */
 
@@ -106,7 +112,7 @@
 /* }}} */
 
 /* {{{ extension definition structures */
-zend_function_entry libxml_functions[] = {
+static zend_function_entry libxml_functions[] = {
PHP_FE(libxml_set_streams_context, arginfo_libxml_set_streams_context)
PHP_FE(libxml_use_internal_errors, arginfo_libxml_use_internal_errors)
PHP_FE(libxml_get_last_error, arginfo_libxml_get_last_error)
@@ -270,7 +276,7 @@
 /* Channel libxml file io layer through the PHP streams subsystem.
  * This allows use of ftps:// and https:// urls */
 
-void *php_libxml_streams_IO_open_wrapper(const char *filename, const char 
*mode, const int read_only)
+static void *php_libxml_streams_IO_open_wrapper(const char *filename, const 
char *mode, const int read_only)
 {
php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
@@ -325,35 +331,35 @@
return ret_val;
 }
 
-void *php_libxml_streams_IO_open_read_wrapper(const char *filename)
+static void *php_libxml_streams_IO_open_read_wrapper(const char *filename)
 {
return php_libxml_streams_IO_open_wrapper(filename, rb, 1);
 }
 
-void *php_libxml_streams_IO_open_write_wrapper(const char *filename)
+static void *php_libxml_streams_IO_open_write_wrapper(const char *filename)
 {
return php_libxml_streams_IO_open_wrapper(filename, wb, 0);
 }
 
-int php_libxml_streams_IO_read(void *context, char *buffer, int len)
+static int php_libxml_streams_IO_read(void *context, char *buffer, int len)
 {
TSRMLS_FETCH();
return php_stream_read((php_stream*)context, buffer, len);
 }
 
-int php_libxml_streams_IO_write(void *context, const char *buffer, int len)
+static int php_libxml_streams_IO_write(void *context, const char *buffer, int 
len)
 {
TSRMLS_FETCH();
return php_stream_write((php_stream*)context, buffer, len);
 }
 
-int php_libxml_streams_IO_close(void *context)
+static int php_libxml_streams_IO_close(void *context)
 {
TSRMLS_FETCH();
return php_stream_close((php_stream*)context);
 }
 
-xmlParserInputBufferPtr
+static xmlParserInputBufferPtr
 php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
 {
 xmlParserInputBufferPtr ret;
@@ -380,7 +386,7 @@
return(ret);
 }
 
-xmlOutputBufferPtr
+static xmlOutputBufferPtr
 php_libxml_output_buffer_create_filename(const char *URI,
   xmlCharEncodingHandlerPtr encoder,
   int compression ATTRIBUTE_UNUSED)
@@ -405,7 +411,7 @@
xmlFree(unescaped);
}
 
-/* try with a non-escaped URI this may be a strange filename */
+   /* try with a non-escaped URI this may be a strange filename */
if (context == NULL) {
context = php_libxml_streams_IO_open_write_wrapper(URI);
}
@@ -590,7 +596,7 @@
 
 }
 
-PHP_MINIT_FUNCTION(libxml)
+static PHP_MINIT_FUNCTION(libxml)
 {
zend_class_entry ce;
 
@@ -630,7 +636,7 @@
 }
 
 
-PHP_RINIT_FUNCTION(libxml)
+static PHP_RINIT_FUNCTION(libxml)
 {
   

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2006-09-06 Thread Edin Kadribasic
edink   Wed Sep  6 21:48:57 2006 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  MFB: Fixed bug #38190 (threading issues on windows 2003)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.52r2=1.53diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.52 php-src/ext/libxml/libxml.c:1.53
--- php-src/ext/libxml/libxml.c:1.52Tue Sep  5 12:42:25 2006
+++ php-src/ext/libxml/libxml.c Wed Sep  6 21:48:57 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.52 2006/09/05 12:42:25 nlopess Exp $ */
+/* $Id: libxml.c,v 1.53 2006/09/06 21:48:57 edink Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -1043,6 +1043,13 @@
 }
 /* }}} */
 
+#ifdef PHP_WIN32
+PHP_LIBXML_API BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID 
lpvReserved)
+{
+   return xmlDllMain(hinstDLL, fdwReason, lpvReserved);
+}
+#endif
+
 #endif
 
 /*

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c /ext/simplexml simplexml.c /ext/simplexml/tests bug38347.phpt

2006-08-06 Thread Antony Dovgal
tony2001Sun Aug  6 17:41:39 2006 UTC

  Added files: 
/php-src/ext/simplexml/testsbug38347.phpt 

  Modified files:  
/php-src/ext/libxml libxml.c 
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix #38347 (Segmentation fault when using foreach with an unknown/empty 
SimpleXMLElement)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.50r2=1.51diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.50 php-src/ext/libxml/libxml.c:1.51
--- php-src/ext/libxml/libxml.c:1.50Tue Jul  4 07:34:32 2006
+++ php-src/ext/libxml/libxml.c Sun Aug  6 17:41:39 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.50 2006/07/04 07:34:32 dmitry Exp $ */
+/* $Id: libxml.c,v 1.51 2006/08/06 17:41:39 tony2001 Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -976,8 +976,8 @@
efree(object-document-doc_props);
}
efree(object-document);
+   object-document = NULL;
}
-   object-document = NULL;
}
 
return ret_refcount;
@@ -1035,6 +1035,8 @@
obj_node-_private = NULL;
}
}
+   }
+   if (object != NULL  object-document != NULL) {
/* Safe to call as if the resource were freed then doc pointer 
is NULL */
php_libxml_decrement_doc_ref(object TSRMLS_CC);
}
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.211r2=1.212diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.211 
php-src/ext/simplexml/simplexml.c:1.212
--- php-src/ext/simplexml/simplexml.c:1.211 Sun Aug  6 13:27:38 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Aug  6 17:41:39 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.211 2006/08/06 13:27:38 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.212 2006/08/06 17:41:39 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -195,6 +195,9 @@
 
if (sxe-iter.type == SXE_ITER_ELEMENT) {
orgnode = sxe_find_element_by_name(sxe, node, sxe-iter.name 
TSRMLS_CC);
+   if (!orgnode) {
+   return NULL;
+   }
node = orgnode-children;
}
 
@@ -2265,7 +2268,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.211 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.212 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug38347.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug38347.phpt
+++ php-src/ext/simplexml/tests/bug38347.phpt
--TEST--
Bug #38347 (Segmentation fault when using foreach with an unknown/empty 
SimpleXMLElement)
--SKIPIF--
?php if (!extension_loaded(simplexml)) print skip; ?
--FILE--
?php

function iterate($xml)
{
print_r($xml);
foreach ($xml-item as $item) {
echo This code will crash!;
}
}

$xmlstr = xmlitemItem 1/itemitemItem 2/item/xml;
$xml = simplexml_load_string($xmlstr);
iterate($xml-unknown);

echo Done\n;
?
--EXPECTF-- 
SimpleXMLElement Object
(
)

Warning: iterate(): Node no longer exists in %s on line %d
Done
--UEXPECTF--
SimpleXMLElement Object
(
)

Warning: iterate(): Node no longer exists in %s on line %d
Done

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2006-07-04 Thread Dmitry Stogov
dmitry  Tue Jul  4 07:34:32 2006 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fixed memory leak
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.49r2=1.50diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.49 php-src/ext/libxml/libxml.c:1.50
--- php-src/ext/libxml/libxml.c:1.49Mon Jun 26 14:10:57 2006
+++ php-src/ext/libxml/libxml.c Tue Jul  4 07:34:32 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.49 2006/06/26 14:10:57 bjori Exp $ */
+/* $Id: libxml.c,v 1.50 2006/07/04 07:34:32 dmitry Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -657,6 +657,10 @@
xmlParserInputBufferCreateFilenameDefault(NULL);
xmlOutputBufferCreateFilenameDefault(NULL);
 
+   if (LIBXML(stream_context)) {
+   zval_ptr_dtor(LIBXML(stream_context));
+   LIBXML(stream_context) = NULL;
+   }
smart_str_free(LIBXML(error_buffer));
if (LIBXML(error_list)) {
zend_llist_destroy(LIBXML(error_list));

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2006-06-17 Thread Hannes Magnusson
bjori   Sat Jun 17 13:15:37 2006 UTC

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Revert accidental libxml class property declaration..
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/libxml/libxml.c?r1=1.47r2=1.48diff_format=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.47 php-src/ext/libxml/libxml.c:1.48
--- php-src/ext/libxml/libxml.c:1.47Sat Jun 17 13:00:21 2006
+++ php-src/ext/libxml/libxml.c Sat Jun 17 13:15:37 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.47 2006/06/17 13:00:21 bjori Exp $ */
+/* $Id: libxml.c,v 1.48 2006/06/17 13:15:37 bjori Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -628,12 +628,6 @@
 
INIT_CLASS_ENTRY(ce, LibXMLError, NULL);
libxmlerror_class_entry = zend_register_internal_class(ce TSRMLS_CC);
-zend_declare_property_long(libxmlerror_class_entry, code, 
sizeof(code)-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
-zend_declare_property_long(libxmlerror_class_entry, level, 
sizeof(level)-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
-zend_declare_property_long(libxmlerror_class_entry, column, 
sizeof(column)-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
-zend_declare_property_string(libxmlerror_class_entry, message, 
sizeof(message)-1, , ZEND_ACC_PUBLIC TSRMLS_CC);
-zend_declare_property_string(libxmlerror_class_entry, file, 
sizeof(file)-1, , ZEND_ACC_PUBLIC TSRMLS_CC);
-zend_declare_property_long(libxmlerror_class_entry, line, 
sizeof(line)-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
 
return SUCCESS;
 }

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2005-11-22 Thread Rob Richards
rrichards   Tue Nov 22 21:54:10 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  move document property struct from xml_common.h
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.39r2=1.40ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.39 php-src/ext/libxml/libxml.c:1.40
--- php-src/ext/libxml/libxml.c:1.39Thu Nov 17 16:57:30 2005
+++ php-src/ext/libxml/libxml.c Tue Nov 22 21:54:10 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.39 2005/11/17 21:57:30 rasmus Exp $ */
+/* $Id: libxml.c,v 1.40 2005/11/23 02:54:10 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -952,6 +952,10 @@
xmlFreeDoc((xmlDoc *) object-document-ptr);
}
if (object-document-doc_props != NULL) {
+   if (object-document-doc_props-classmap) {
+   
zend_hash_destroy(object-document-doc_props-classmap);
+   
FREE_HASHTABLE(object-document-doc_props-classmap);
+   }
efree(object-document-doc_props);
}
efree(object-document);
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.16r2=1.17ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.16 
php-src/ext/libxml/php_libxml.h:1.17
--- php-src/ext/libxml/php_libxml.h:1.16Thu Sep  8 06:33:57 2005
+++ php-src/ext/libxml/php_libxml.h Tue Nov 22 21:54:10 2005
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.16 2005/09/08 10:33:57 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.17 2005/11/23 02:54:10 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -43,10 +43,21 @@
zend_llist *error_list;
 } php_libxml_globals;
 
+typedef struct _libxml_doc_props {
+   int formatoutput;
+   int validateonparse;
+   int resolveexternals;
+   int preservewhitespace;
+   int substituteentities;
+   int stricterror;
+   int recover;
+   HashTable *classmap;
+} libxml_doc_props;
+
 typedef struct _php_libxml_ref_obj {
void *ptr;
int   refcount;
-   void *doc_props;
+   libxml_doc_props *doc_props;
 } php_libxml_ref_obj;
 
 typedef struct _php_libxml_node_ptr {

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-11-17 Thread Rasmus Lerdorf
rasmus  Thu Nov 17 16:57:30 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  MFB: missing }}}
  
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.38r2=1.39ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.38 php-src/ext/libxml/libxml.c:1.39
--- php-src/ext/libxml/libxml.c:1.38Mon Oct 17 15:47:23 2005
+++ php-src/ext/libxml/libxml.c Thu Nov 17 16:57:30 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.38 2005/10/17 19:47:23 rrichards Exp $ */
+/* $Id: libxml.c,v 1.39 2005/11/17 21:57:30 rasmus Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -665,7 +665,6 @@
 }
 /* }}} */
 
-
 /* {{{ proto void libxml_set_streams_context(resource streams_context) 
Set the streams context for the next libxml document load or write */
 PHP_FUNCTION(libxml_set_streams_context)
@@ -722,6 +721,7 @@
}
RETURN_BOOL(retval);
 }
+/* }}} */
 
 /* {{{ proto object libxml_get_last_error() 
Retrieve last error from libxml */

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-10-17 Thread Rob Richards
rrichards   Mon Oct 17 15:47:35 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  only need context set once
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.37r2=1.38ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.37 php-src/ext/libxml/libxml.c:1.38
--- php-src/ext/libxml/libxml.c:1.37Thu Oct 13 16:17:18 2005
+++ php-src/ext/libxml/libxml.c Mon Oct 17 15:47:23 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.37 2005/10/13 20:17:18 rrichards Exp $ */
+/* $Id: libxml.c,v 1.38 2005/10/17 19:47:23 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -386,7 +386,7 @@
 
 /* try with a non-escaped URI this may be a strange filename */
if (context == NULL) {
-   context = context = 
php_libxml_streams_IO_open_write_wrapper(URI);
+   context = php_libxml_streams_IO_open_write_wrapper(URI);
}
 
if (context == NULL) {

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-10-13 Thread Rob Richards
rrichards   Thu Oct 13 16:17:18 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  insure stream usage
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.36r2=1.37ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.36 php-src/ext/libxml/libxml.c:1.37
--- php-src/ext/libxml/libxml.c:1.36Thu Sep  8 06:33:57 2005
+++ php-src/ext/libxml/libxml.c Thu Oct 13 16:17:18 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.36 2005/09/08 10:33:57 rrichards Exp $ */
+/* $Id: libxml.c,v 1.37 2005/10/13 20:17:18 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -249,36 +249,6 @@
 /* Channel libxml file io layer through the PHP streams subsystem.
  * This allows use of ftps:// and https:// urls */
 
-int php_libxml_streams_IO_match_wrapper(const char *filename)
-{
-   char *resolved_path;
-   int retval, isescaped=0;
-   xmlURI *uri;
-
-   TSRMLS_FETCH();
-
-   if (zend_is_executing(TSRMLS_C)) {
-   uri = xmlParseURI((xmlChar *)filename);
-   if (uri  (uri-scheme == NULL || (xmlStrncmp(uri-scheme, 
file, 4) == 0))) {
-   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
-   isescaped = 1;
-   } else {
-   resolved_path = (char *)filename;
-   }
-
-   if (uri) {
-   xmlFreeURI(uri);
-   }
-
-   retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 
TSRMLS_CC) ? 1 : 0;
-   if (resolved_path  isescaped) {
-   xmlFree(resolved_path);
-   }
-   return retval;
-   }
-   return 0;
-}
-
 void *php_libxml_streams_IO_open_wrapper(const char *filename, const char 
*mode, const int read_only)
 {
php_stream_statbuf ssbuf;
@@ -362,6 +332,78 @@
return php_stream_close((php_stream*)context);
 }
 
+xmlParserInputBufferPtr
+php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
+{
+xmlParserInputBufferPtr ret;
+void *context = NULL;
+
+if (URI == NULL)
+   return(NULL);
+
+   context = php_libxml_streams_IO_open_read_wrapper(URI);
+
+   if (context == NULL) {
+   return(NULL);
+   }
+
+   /* Allocate the Input buffer front-end. */
+   ret = xmlAllocParserInputBuffer(enc);
+   if (ret != NULL) {
+   ret-context = context;
+   ret-readcallback = php_libxml_streams_IO_read;
+   ret-closecallback = php_libxml_streams_IO_close;
+   } else
+   php_libxml_streams_IO_close(context);
+
+   return(ret);
+}
+
+xmlOutputBufferPtr
+php_libxml_output_buffer_create_filename(const char *URI,
+  xmlCharEncodingHandlerPtr encoder,
+  int compression ATTRIBUTE_UNUSED)
+{
+xmlOutputBufferPtr ret;
+xmlURIPtr puri;
+void *context = NULL;
+char *unescaped = NULL;
+
+   if (URI == NULL)
+   return(NULL);
+
+   puri = xmlParseURI(URI);
+   if (puri != NULL) {
+   if (puri-scheme != NULL)
+   unescaped = xmlURIUnescapeString(URI, 0, NULL);
+   xmlFreeURI(puri);
+   }
+
+   if (unescaped != NULL) {
+   context = php_libxml_streams_IO_open_write_wrapper(unescaped);
+   xmlFree(unescaped);
+   }
+
+/* try with a non-escaped URI this may be a strange filename */
+   if (context == NULL) {
+   context = context = 
php_libxml_streams_IO_open_write_wrapper(URI);
+   }
+
+   if (context == NULL) {
+   return(NULL);
+   }
+
+   /* Allocate the Output buffer front-end. */
+   ret = xmlAllocOutputBuffer(encoder);
+   if (ret != NULL) {
+   ret-context = context;
+   ret-writecallback = php_libxml_streams_IO_write;
+   ret-closecallback = php_libxml_streams_IO_close;
+   }
+
+   return(ret);
+}
+
 static int _php_libxml_free_error(xmlErrorPtr error) {
/* This will free the libxml alloc'd memory */
xmlResetError(error);
@@ -501,22 +543,6 @@
/* we should be the only one's to ever init!! */
xmlInitParser();
 
-   /* Enable php stream/wrapper support for libxml 
-  we only use php streams, so we do not enable
-  the default io handlers in libxml.
-   */
-   xmlRegisterInputCallbacks(
-   php_libxml_streams_IO_match_wrapper, 
-   php_libxml_streams_IO_open_read_wrapper,
-   php_libxml_streams_IO_read, 
-   php_libxml_streams_IO_close);
-
-   xmlRegisterOutputCallbacks(
-   php_libxml_streams_IO_match_wrapper, 
-

[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2005-09-08 Thread Rob Richards
rrichards   Thu Sep  8 06:33:58 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  add additional constants
  remove un-needed ifdefs
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.35r2=1.36ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.35 php-src/ext/libxml/libxml.c:1.36
--- php-src/ext/libxml/libxml.c:1.35Thu Aug 25 22:29:32 2005
+++ php-src/ext/libxml/libxml.c Thu Sep  8 06:33:57 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.35 2005/08/26 02:29:32 rrichards Exp $ */
+/* $Id: libxml.c,v 1.36 2005/09/08 10:33:57 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -40,6 +40,7 @@
 #include libxml/tree.h
 #include libxml/uri.h
 #include libxml/xmlerror.h
+#include libxml/xmlsave.h
 #ifdef LIBXML_SCHEMAS_ENABLED
 #include libxml/relaxng.h
 #endif
@@ -65,9 +66,7 @@
 PHP_LIBXML_API php_libxml_globals libxml_globals;
 #endif
 
-#if LIBXML_VERSION = 20600
 zend_class_entry *libxmlerror_class_entry;
-#endif
 
 /* {{{ dynamically loadable module stuff */
 #ifdef COMPILE_DL_LIBXML
@@ -546,9 +545,7 @@
 
 PHP_MINIT_FUNCTION(libxml)
 {
-#if LIBXML_VERSION = 20600
zend_class_entry ce;
-#endif
 
php_libxml_initialize();
 
@@ -563,7 +560,6 @@
REGISTER_LONG_CONSTANT(LIBXML_VERSION,
LIBXML_VERSION, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT(LIBXML_DOTTED_VERSION,   
LIBXML_DOTTED_VERSION,  CONST_CS | CONST_PERSISTENT);
 
-#if LIBXML_VERSION = 20600
/* For use with loading xml */
REGISTER_LONG_CONSTANT(LIBXML_NOENT,  XML_PARSE_NOENT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(LIBXML_DTDLOAD,XML_PARSE_DTDLOAD,  
CONST_CS | CONST_PERSISTENT);
@@ -576,6 +572,11 @@
REGISTER_LONG_CONSTANT(LIBXML_NSCLEAN,XML_PARSE_NSCLEAN,  
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(LIBXML_NOCDATA,XML_PARSE_NOCDATA,  
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(LIBXML_NONET,  XML_PARSE_NONET,
CONST_CS | CONST_PERSISTENT);
+#if LIBXML_VERSION = 20621
+   REGISTER_LONG_CONSTANT(LIBXML_COMPACT,XML_PARSE_COMPACT,  
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NOXMLDECL,  XML_SAVE_NO_DECL,   
CONST_CS | CONST_PERSISTENT);
+#endif
+   REGISTER_LONG_CONSTANT(LIBXML_NOEMPTYTAG, LIBXML_SAVE_NOEMPTYTAG, 
CONST_CS | CONST_PERSISTENT);
 
/* Error levels */
REGISTER_LONG_CONSTANT(LIBXML_ERR_NONE,   XML_ERR_NONE,   
CONST_CS | CONST_PERSISTENT);
@@ -585,7 +586,6 @@
 
INIT_CLASS_ENTRY(ce, LibXMLError, NULL);
libxmlerror_class_entry = zend_register_internal_class(ce TSRMLS_CC);
-#endif
 
return SUCCESS;
 }
@@ -657,7 +657,6 @@
Disable libxml errors and allow user to fetch error information as needed */
 PHP_FUNCTION(libxml_use_internal_errors)
 {
-#if LIBXML_VERSION = 20600
xmlStructuredErrorFunc current_handler;
int use_errors=0, retval;
 
@@ -691,16 +690,12 @@
}
}
RETURN_BOOL(retval);
-#else
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Libxml 2.6 or higher is 
required);
-#endif
 }
 
 /* {{{ proto object libxml_get_last_error() 
Retrieve last error from libxml */
 PHP_FUNCTION(libxml_get_last_error)
 {
-#if LIBXML_VERSION = 20600
xmlErrorPtr error;
 
error = xmlGetLastError();
@@ -724,9 +719,6 @@
} else {
RETURN_FALSE;
}
-#else
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Libxml 2.6 or higher is 
required);
-#endif
 }
 /* }}} */
 
@@ -734,7 +726,6 @@
Retrieve array of errors */
 PHP_FUNCTION(libxml_get_errors)
 {
-#if LIBXML_VERSION = 20600

xmlErrorPtr error;
 
@@ -770,9 +761,6 @@
error = zend_llist_get_next(LIBXML(error_list));
}
}
-#else
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Libxml 2.6 or higher is 
required);
-#endif
 }
 /* }}} */
 
@@ -780,14 +768,10 @@
 Clear last error from libxml */
 PHP_FUNCTION(libxml_clear_errors)
 {
-#if LIBXML_VERSION = 20600
xmlResetLastError();
if (LIBXML(error_list)) {
zend_llist_clean(LIBXML(error_list));
}
-#else
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Libxml 2.6 or higher is 
required);
-#endif
 }
 /* }}} */
 
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.15r2=1.16ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.15 
php-src/ext/libxml/php_libxml.h:1.16
--- php-src/ext/libxml/php_libxml.h:1.15Wed Aug  3 10:07:23 2005
+++ php-src/ext/libxml/php_libxml.h Thu Sep  8 06:33:57 2005
@@ -17,7 +17,7 @@

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-08-25 Thread Dmitry Stogov
dmitry  Thu Aug 25 09:53:39 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fixed memory leaks
  
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.33r2=1.34ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.33 php-src/ext/libxml/libxml.c:1.34
--- php-src/ext/libxml/libxml.c:1.33Thu Aug 18 03:16:52 2005
+++ php-src/ext/libxml/libxml.c Thu Aug 25 09:53:38 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.33 2005/08/18 07:16:52 dmitry Exp $ */
+/* $Id: libxml.c,v 1.34 2005/08/25 13:53:38 dmitry Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -798,11 +798,14 @@
export_hnd.export_func = export_function;
 
if (zend_hash_add(php_libxml_exports, ce-name, ce-name_length + 1, 
export_hnd, sizeof(export_hnd), NULL) == SUCCESS) {
+   int ret;
UChar *uname;
 
uname = malloc(UBYTES(ce-name_length+1));
u_charsToUChars(ce-name, uname, ce-name_length+1);
-return zend_u_hash_add(php_libxml_exports, IS_UNICODE, uname, 
ce-name_length + 1, export_hnd, sizeof(export_hnd), NULL);
+ret = zend_u_hash_add(php_libxml_exports, IS_UNICODE, uname, 
ce-name_length + 1, export_hnd, sizeof(export_hnd), NULL);
+free(uname);
+return ret;
   }
   return FAILURE;
 }

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-08-25 Thread Rob Richards
rrichards   Thu Aug 25 22:29:34 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fix URI escaping
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.34r2=1.35ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.34 php-src/ext/libxml/libxml.c:1.35
--- php-src/ext/libxml/libxml.c:1.34Thu Aug 25 09:53:38 2005
+++ php-src/ext/libxml/libxml.c Thu Aug 25 22:29:32 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.34 2005/08/25 13:53:38 dmitry Exp $ */
+/* $Id: libxml.c,v 1.35 2005/08/26 02:29:32 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -253,14 +253,26 @@
 int php_libxml_streams_IO_match_wrapper(const char *filename)
 {
char *resolved_path;
-   int retval;
+   int retval, isescaped=0;
+   xmlURI *uri;
 
TSRMLS_FETCH();
 
if (zend_is_executing(TSRMLS_C)) {
-   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+   uri = xmlParseURI((xmlChar *)filename);
+   if (uri  (uri-scheme == NULL || (xmlStrncmp(uri-scheme, 
file, 4) == 0))) {
+   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+   isescaped = 1;
+   } else {
+   resolved_path = (char *)filename;
+   }
+
+   if (uri) {
+   xmlFreeURI(uri);
+   }
+
retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 
TSRMLS_CC) ? 1 : 0;
-   if (resolved_path) {
+   if (resolved_path  isescaped) {
xmlFree(resolved_path);
}
return retval;
@@ -275,9 +287,22 @@
php_stream_wrapper *wrapper = NULL;
char *resolved_path, *path_to_open = NULL;
void *ret_val = NULL;
+   int isescaped=0;
+   xmlURI *uri;
 
TSRMLS_FETCH();
-   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+
+   uri = xmlParseURI((xmlChar *)filename);
+   if (uri  (uri-scheme == NULL || (xmlStrncmp(uri-scheme, file, 4) 
== 0))) {
+   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+   isescaped = 1;
+   } else {
+   resolved_path = (char *)filename;
+   }
+
+   if (uri) {
+   xmlFreeURI(uri);
+   }
 
if (resolved_path == NULL) {
return NULL;
@@ -292,7 +317,9 @@
wrapper = php_stream_locate_url_wrapper(resolved_path, path_to_open, 
ENFORCE_SAFE_MODE TSRMLS_CC);
if (wrapper  read_only  wrapper-wops-url_stat) {
if (wrapper-wops-url_stat(wrapper, path_to_open, 
PHP_STREAM_URL_STAT_QUIET, ssbuf, NULL TSRMLS_CC) == -1) {
-   xmlFree(resolved_path);
+   if (isescaped) {
+   xmlFree(resolved_path);
+   }
return NULL;
}
}
@@ -302,7 +329,9 @@
}
 
ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
-   xmlFree(resolved_path);
+   if (isescaped) {
+   xmlFree(resolved_path);
+   }
return ret_val;
 }
 


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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-08-18 Thread Dmitry Stogov
dmitry  Thu Aug 18 03:16:53 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Unicode support
  
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.32r2=1.33ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.32 php-src/ext/libxml/libxml.c:1.33
--- php-src/ext/libxml/libxml.c:1.32Wed Aug  3 10:07:23 2005
+++ php-src/ext/libxml/libxml.c Thu Aug 18 03:16:52 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.32 2005/08/03 14:07:23 sniper Exp $ */
+/* $Id: libxml.c,v 1.33 2005/08/18 07:16:52 dmitry Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -797,7 +797,14 @@
php_libxml_initialize();
export_hnd.export_func = export_function;
 
-return zend_hash_add(php_libxml_exports, ce-name, ce-name_length + 1, 
export_hnd, sizeof(export_hnd), NULL);
+   if (zend_hash_add(php_libxml_exports, ce-name, ce-name_length + 1, 
export_hnd, sizeof(export_hnd), NULL) == SUCCESS) {
+   UChar *uname;
+
+   uname = malloc(UBYTES(ce-name_length+1));
+   u_charsToUChars(ce-name, uname, ce-name_length+1);
+return zend_u_hash_add(php_libxml_exports, IS_UNICODE, uname, 
ce-name_length + 1, export_hnd, sizeof(export_hnd), NULL);
+  }
+  return FAILURE;
 }
 
 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC)
@@ -811,10 +818,10 @@
while (ce-parent != NULL) {
ce = ce-parent;
}
-   if (zend_hash_find(php_libxml_exports, ce-name, 
ce-name_length + 1, (void **) export_hnd)  == SUCCESS) {
+   if (zend_u_hash_find(php_libxml_exports, 
UG(unicode)?IS_UNICODE:IS_STRING, ce-name, ce-name_length + 1, (void **) 
export_hnd)  == SUCCESS) {
node = export_hnd-export_func(object TSRMLS_CC);
}
-}
+   }
 
return node;
 

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-02-28 Thread Pierre-Alain Joye
pajoye  Mon Feb 28 03:13:36 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  - create LIBXML_VERSION and LIBXML_DOTTED_VERSION constants
  
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.29r2=1.30ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.29 php-src/ext/libxml/libxml.c:1.30
--- php-src/ext/libxml/libxml.c:1.29Sun Feb 20 16:49:45 2005
+++ php-src/ext/libxml/libxml.c Mon Feb 28 03:13:35 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.29 2005/02/20 21:49:45 rrichards Exp $ */
+/* $Id: libxml.c,v 1.30 2005/02/28 08:13:35 pajoye Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -530,6 +530,8 @@
LIBXML(error_buffer).c = NULL;
LIBXML(error_list) = NULL;
 #endif
+   REGISTER_LONG_CONSTANT(LIBXML_VERSION,
LIBXML_VERSION, CONST_CS | CONST_PERSISTENT);
+   REGISTER_STRING_CONSTANT(LIBXML_DOTTED_VERSION,   
LIBXML_DOTTED_VERSION,  CONST_CS | CONST_PERSISTENT);
 
 #if LIBXML_VERSION = 20600
/* For use with loading xml */

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2005-02-20 Thread Rob Richards
rrichards   Sun Feb 20 16:49:45 2005 EDT

  Modified files:  
/php-src/ext/libxml php_libxml.h libxml.c 
  Log:
  add function to allow extensions to use new error handling if set by user
  
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.12r2=1.13ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.12 
php-src/ext/libxml/php_libxml.h:1.13
--- php-src/ext/libxml/php_libxml.h:1.12Thu Feb 10 10:52:38 2005
+++ php-src/ext/libxml/php_libxml.h Sun Feb 20 16:49:45 2005
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.12 2005/02/10 15:52:38 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.13 2005/02/20 21:49:45 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -88,6 +88,7 @@
 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);
 
 #endif /* HAVE_LIBXML */
 
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.28r2=1.29ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.28 php-src/ext/libxml/libxml.c:1.29
--- php-src/ext/libxml/libxml.c:1.28Thu Feb 10 10:52:38 2005
+++ php-src/ext/libxml/libxml.c Sun Feb 20 16:49:45 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.28 2005/02/10 15:52:38 rrichards Exp $ */
+/* $Id: libxml.c,v 1.29 2005/02/20 21:49:45 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -388,6 +388,15 @@
}
 }
 
+void php_libxml_issue_error(int level, const char *msg TSRMLS_DC)
+{
+   if (LIBXML(error_list)) {
+   _php_list_set_error_structure(NULL, msg);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, level, %s, msg);
+   }
+}
+
 static void php_libxml_internal_error_handler(int error_type, void *ctx, const 
char **msg, va_list ap)
 {
char *buf;

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2005-02-10 Thread Rob Richards
rrichards   Thu Feb 10 10:52:39 2005 EDT

  Modified files:  
/php-src/ext/libxml php_libxml.h libxml.c 
  Log:
  initial cut of new error handling
  http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.11r2=1.12ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.11 
php-src/ext/libxml/php_libxml.h:1.12
--- php-src/ext/libxml/php_libxml.h:1.11Tue Nov  9 03:13:35 2004
+++ php-src/ext/libxml/php_libxml.h Thu Feb 10 10:52:38 2005
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.11 2004/11/09 08:13:35 dmitry Exp $ */
+/* $Id: php_libxml.h,v 1.12 2005/02/10 15:52:38 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -43,6 +43,7 @@
 typedef struct {
zval *stream_context;
smart_str error_buffer;
+   zend_llist *error_list;
 } php_libxml_globals;
 
 typedef struct _php_libxml_ref_obj {
@@ -67,11 +68,15 @@
 typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
 
 PHP_FUNCTION(libxml_set_streams_context);
+PHP_FUNCTION(libxml_use_internal_errors);
+PHP_FUNCTION(libxml_get_last_error);
+PHP_FUNCTION(libxml_clear_errors);
+PHP_FUNCTION(libxml_get_errors);
 
 int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr 
node, void *private_data TSRMLS_DC);
 int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
-int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr 
docp TSRMLS_DC);
-int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC);
+PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object 
*object, xmlDocPtr docp TSRMLS_DC);
+PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object 
TSRMLS_DC);
 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);
 PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, 
php_libxml_export_node export_function);
 /* When an explicit freeing of node and children is required */
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.27r2=1.28ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.27 php-src/ext/libxml/libxml.c:1.28
--- php-src/ext/libxml/libxml.c:1.27Sun Jan  2 07:21:14 2005
+++ php-src/ext/libxml/libxml.c Thu Feb 10 10:52:38 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.27 2005/01/02 12:21:14 rrichards Exp $ */
+/* $Id: libxml.c,v 1.28 2005/02/10 15:52:38 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -65,6 +65,10 @@
 PHP_LIBXML_API php_libxml_globals libxml_globals;
 #endif
 
+#if LIBXML_VERSION = 20600
+zend_class_entry *libxmlerror_class_entry;
+#endif
+
 /* {{{ dynamically loadable module stuff */
 #ifdef COMPILE_DL_LIBXML
 ZEND_GET_MODULE(libxml)
@@ -86,6 +90,10 @@
 /* {{{ extension definition structures */
 function_entry libxml_functions[] = {
PHP_FE(libxml_set_streams_context, NULL)
+   PHP_FE(libxml_use_internal_errors, NULL)
+   PHP_FE(libxml_get_last_error, NULL)
+   PHP_FE(libxml_clear_errors, NULL)
+   PHP_FE(libxml_get_errors, NULL)
{NULL, NULL, NULL}
 };
 
@@ -235,6 +243,7 @@
 {
LIBXML(stream_context) = NULL;
LIBXML(error_buffer).c = NULL;
+   LIBXML(error_list) = NULL;
 }
 #endif
 
@@ -325,6 +334,45 @@
return php_stream_close((php_stream*)context);
 }
 
+static int _php_libxml_free_error(xmlErrorPtr error) {
+   /* This will free the libxml alloc'd memory */
+   xmlResetError(error);
+   return 1;
+}
+
+static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg)
+{
+   xmlError error_copy;
+   int ret;
+
+   TSRMLS_FETCH();
+
+   memset(error_copy, 0, sizeof(xmlError));
+
+   if (error) {
+   ret = xmlCopyError(error, error_copy);
+   } else {
+   error_copy.domain = 0;
+   error_copy.code = XML_ERR_INTERNAL_ERROR;
+   error_copy.level = XML_ERR_ERROR;
+   error_copy.line = 0;
+   error_copy.node = NULL;
+   error_copy.int1 = 0;
+   error_copy.int2 = 0;
+   error_copy.ctxt = NULL;
+   error_copy.message = xmlStrdup(msg);
+   error_copy.file = NULL;
+   error_copy.str1 = NULL;
+   error_copy.str2 = NULL;
+   error_copy.str3 = NULL;
+   ret = 0;
+   }
+
+   if (ret == 0) {
+   zend_llist_add_element(LIBXML(error_list), error_copy);
+   }
+}
+
 static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg 
TSRMLS_DC)
 {
xmlParserCtxtPtr parser;
@@ -361,15 +409,19 @@
efree(buf);
 
if (output == 1) {
-   switch (error_type) {
-   case PHP_LIBXML_CTX_ERROR:
-   

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2005-01-02 Thread Rob Richards
rrichards   Sun Jan  2 07:08:41 2005 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fixed bug #31361 (simplexml/domxml segfault when adding node twice)
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.25r2=1.26ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.25 php-src/ext/libxml/libxml.c:1.26
--- php-src/ext/libxml/libxml.c:1.25Sun Dec  5 06:59:46 2004
+++ php-src/ext/libxml/libxml.c Sun Jan  2 07:08:41 2005
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.25 2004/12/05 11:59:46 rrichards Exp $ */
+/* $Id: libxml.c,v 1.26 2005/01/02 12:08:41 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -725,6 +725,10 @@
ret_refcount = php_libxml_decrement_node_ptr(object TSRMLS_CC);
if (ret_refcount == 0) {
php_libxml_node_free_resource(nodep TSRMLS_CC);
+   } else {
+   if (obj_node  object == obj_node-_private) {
+   obj_node-_private = NULL;
+   }
}
/* Safe to call as if the resource were freed then doc pointer 
is NULL */
php_libxml_decrement_doc_ref(object TSRMLS_CC);

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-12-05 Thread Rob Richards
rrichards   Sun Dec  5 06:59:46 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  define options that can be used when loading documents
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.24r2=1.25ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.24 php-src/ext/libxml/libxml.c:1.25
--- php-src/ext/libxml/libxml.c:1.24Tue Nov  9 03:13:35 2004
+++ php-src/ext/libxml/libxml.c Sun Dec  5 06:59:46 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.24 2004/11/09 08:13:35 dmitry Exp $ */
+/* $Id: libxml.c,v 1.25 2004/12/05 11:59:46 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -458,6 +458,20 @@
LIBXML(error_buffer).c = NULL;
 #endif
 
+#if LIBXML_VERSION = 20600
+   /* For use with loading xml */
+   REGISTER_LONG_CONSTANT(LIBXML_NOENT,  XML_PARSE_NOENT,
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_DTDLOAD,XML_PARSE_DTDLOAD,  
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_DTDATTR,XML_PARSE_DTDATTR,  
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_DTDVALID,   XML_PARSE_DTDVALID, 
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NOERROR,XML_PARSE_NOERROR,  
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NOWARNING,  XML_PARSE_NOWARNING,
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NOBLANKS,   XML_PARSE_NOBLANKS, 
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_XINCLUDE,   XML_PARSE_XINCLUDE, 
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NSCLEAN,XML_PARSE_NSCLEAN,  
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(LIBXML_NOCDATA,XML_PARSE_NOCDATA,  
CONST_CS | CONST_PERSISTENT);
+#endif
+
return SUCCESS;
 }
 

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h /ext/soap php_sdl.c php_sdl.h soap.c

2004-11-09 Thread Dmitry Stogov
dmitry  Tue Nov  9 03:13:36 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
/php-src/ext/soap   php_sdl.c php_sdl.h soap.c 
  Log:
  Fixed bug #29211 (SoapClient doesn't request wsdl through proxy). (Rob)
  
  http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.23r2=1.24ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.23 php-src/ext/libxml/libxml.c:1.24
--- php-src/ext/libxml/libxml.c:1.23Wed Sep  8 06:15:41 2004
+++ php-src/ext/libxml/libxml.c Tue Nov  9 03:13:35 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.23 2004/09/08 10:15:41 rrichards Exp $ */
+/* $Id: libxml.c,v 1.24 2004/11/09 08:13:35 dmitry Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -243,10 +243,18 @@
 
 int php_libxml_streams_IO_match_wrapper(const char *filename)
 {
+   char *resolved_path;
+   int retval;
+
TSRMLS_FETCH();
 
if (zend_is_executing(TSRMLS_C)) {
-   return php_stream_locate_url_wrapper(filename, NULL, 0 
TSRMLS_CC) ? 1 : 0;
+   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+   retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 
TSRMLS_CC) ? 1 : 0;
+   if (resolved_path) {
+   xmlFree(resolved_path);
+   }
+   return retval;
}
return 0;
 }
@@ -274,7 +282,7 @@
   in xml processing (eg. DTD files)  */
wrapper = php_stream_locate_url_wrapper(resolved_path, path_to_open, 
ENFORCE_SAFE_MODE TSRMLS_CC);
if (wrapper  read_only  wrapper-wops-url_stat) {
-   if (wrapper-wops-url_stat(wrapper, path_to_open, 0, ssbuf, 
NULL TSRMLS_CC) == -1) {
+   if (wrapper-wops-url_stat(wrapper, path_to_open, 
PHP_STREAM_URL_STAT_QUIET, ssbuf, NULL TSRMLS_CC) == -1) {
xmlFree(resolved_path);
return NULL;
}
@@ -282,11 +290,9 @@
 
if (LIBXML(stream_context)) {
context = zend_fetch_resource(LIBXML(stream_context) 
TSRMLS_CC, -1, Stream-Context, NULL, 1, php_le_stream_context());
-   ret_val = php_stream_open_wrapper_ex(path_to_open, (char 
*)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
-   xmlFree(resolved_path);
-   return ret_val;
}
-   ret_val = php_stream_open_wrapper(path_to_open, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+
+   ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
xmlFree(resolved_path);
return ret_val;
 }
@@ -432,6 +438,15 @@
}
 }
 
+PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC) {
+   zval *oldcontext;
+
+   oldcontext = LIBXML(stream_context);
+   LIBXML(stream_context) = context;
+   return oldcontext;
+
+}
+
 PHP_MINIT_FUNCTION(libxml)
 {
php_libxml_initialize();
@@ -503,7 +518,6 @@
 }
 /* }}} */
 
-
 /* {{{ Common functions shared by extensions */
 int php_libxml_xmlCheckUTF8(const unsigned char *s)
 {
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.10r2=1.11ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.10 
php-src/ext/libxml/php_libxml.h:1.11
--- php-src/ext/libxml/php_libxml.h:1.10Wed Sep  8 06:15:41 2004
+++ php-src/ext/libxml/php_libxml.h Tue Nov  9 03:13:35 2004
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.10 2004/09/08 10:15:41 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.11 2004/11/09 08:13:35 dmitry Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -67,6 +67,7 @@
 typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
 
 PHP_FUNCTION(libxml_set_streams_context);
+
 int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr 
node, void *private_data TSRMLS_DC);
 int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
 int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr 
docp TSRMLS_DC);
@@ -81,6 +82,7 @@
 void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
 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);
 
 #endif /* HAVE_LIBXML */
 
http://cvs.php.net/diff.php/php-src/ext/soap/php_sdl.c?r1=1.75r2=1.76ty=u
Index: php-src/ext/soap/php_sdl.c
diff -u php-src/ext/soap/php_sdl.c:1.75 php-src/ext/soap/php_sdl.c:1.76
--- php-src/ext/soap/php_sdl.c:1.75 Sun Sep 26 17:45:17 2004
+++ php-src/ext/soap/php_sdl.c  Tue Nov  9 03:13:35 2004
@@ -17,9 +17,10 @@
   |  Dmitry Stogov [EMAIL PROTECTED] |
   

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-09-06 Thread Rob Richards
rrichards   Mon Sep  6 06:16:34 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fixed bug #29945 (simplexml_load_file URL limitation 255 char)
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.21r2=1.22ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.21 php-src/ext/libxml/libxml.c:1.22
--- php-src/ext/libxml/libxml.c:1.21Sun Jul 25 08:00:28 2004
+++ php-src/ext/libxml/libxml.c Mon Sep  6 06:16:34 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.21 2004/07/25 12:00:28 rrichards Exp $ */
+/* $Id: libxml.c,v 1.22 2004/09/06 10:16:34 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -253,15 +253,18 @@
 
 void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, 
const int read_only)
 {
-   char resolved_path[MAXPATHLEN + 1];
php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
php_stream_wrapper *wrapper = NULL;
-   char *path_to_open = NULL;
+   char *resolved_path, *path_to_open = NULL;
+   void *ret_val = NULL;
 
TSRMLS_FETCH();
-   xmlURIUnescapeString(filename, 0, resolved_path);
-   path_to_open = resolved_path;
+   resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+
+   if (resolved_path == NULL) {
+   return NULL;
+   }
 
/* logic copied from _php_stream_stat, but we only want to fail
   if the wrapper supports stat, otherwise, figure it out from
@@ -272,15 +275,20 @@
wrapper = php_stream_locate_url_wrapper(resolved_path, path_to_open, 
ENFORCE_SAFE_MODE TSRMLS_CC);
if (wrapper  read_only  wrapper-wops-url_stat) {
if (wrapper-wops-url_stat(wrapper, path_to_open, 0, ssbuf, NULL 
TSRMLS_CC) == -1) {
+   xmlFree(resolved_path);
return NULL;
}
}
 
if (LIBXML(stream_context)) {
context = zend_fetch_resource(LIBXML(stream_context) TSRMLS_CC, -1, 
Stream-Context, NULL, 1, php_le_stream_context());
-   return php_stream_open_wrapper_ex((char *)resolved_path, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
+   ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
+   xmlFree(resolved_path);
+   return ret_val;
}
-   return php_stream_open_wrapper((char *)resolved_path, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+   ret_val = php_stream_open_wrapper(path_to_open, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+   xmlFree(resolved_path);
+   return ret_val;
 }
 
 void *php_libxml_streams_IO_open_read_wrapper(const char *filename)

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-07-25 Thread Christian Stocker
chregu  Sun Jul 25 06:37:28 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  use php_error_docref for libxml2 errors
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.19r2=1.20ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.19 php-src/ext/libxml/libxml.c:1.20
--- php-src/ext/libxml/libxml.c:1.19Sun Jul 18 07:45:12 2004
+++ php-src/ext/libxml/libxml.c Sun Jul 25 06:37:27 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.19 2004/07/18 11:45:12 rrichards Exp $ */
+/* $Id: libxml.c,v 1.20 2004/07/25 10:37:27 chregu Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -355,7 +355,7 @@
php_libxml_ctx_error_level(E_NOTICE, ctx, 
LIBXML(error_buffer).c TSRMLS_CC);
break;
default:
-   php_error(E_WARNING, %s, LIBXML(error_buffer).c);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, 
LIBXML(error_buffer).c);
}
smart_str_free(LIBXML(error_buffer));
}

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2004-07-25 Thread Rob Richards
rrichards   Sun Jul 25 08:00:28 2004 EDT

  Modified files:  
/php-src/ext/libxml php_libxml.h libxml.c 
  Log:
  export php_libxml_error_handler for win32 build
  
http://cvs.php.net/diff.php/php-src/ext/libxml/php_libxml.h?r1=1.8r2=1.9ty=u
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.8 php-src/ext/libxml/php_libxml.h:1.9
--- php-src/ext/libxml/php_libxml.h:1.8 Mon Mar  1 07:09:22 2004
+++ php-src/ext/libxml/php_libxml.h Sun Jul 25 08:00:28 2004
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.8 2004/03/01 12:09:22 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.9 2004/07/25 12:00:28 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -77,7 +77,7 @@
 void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
 /* When object dtor is called as node may still be referenced */
 void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
-void php_libxml_error_handler(void *ctx, const char *msg, ...);
+PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
 void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
 void php_libxml_ctx_error(void *ctx, const char *msg, ...);
 
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.20r2=1.21ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.20 php-src/ext/libxml/libxml.c:1.21
--- php-src/ext/libxml/libxml.c:1.20Sun Jul 25 06:37:27 2004
+++ php-src/ext/libxml/libxml.c Sun Jul 25 08:00:28 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.20 2004/07/25 10:37:27 chregu Exp $ */
+/* $Id: libxml.c,v 1.21 2004/07/25 12:00:28 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -377,7 +377,7 @@
va_end(args);
 }
 
-void php_libxml_error_handler(void *ctx, const char *msg, ...)
+PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...)
 {
va_list args;
va_start(args, msg);

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-07-18 Thread Rob Richards
rrichards   Sun Jul 18 07:45:12 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  MFB: Fixed bug #29221 (Segfault using DOM ownerDocument in a PHP object)
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.18r2=1.19ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.18 php-src/ext/libxml/libxml.c:1.19
--- php-src/ext/libxml/libxml.c:1.18Mon May 31 07:20:46 2004
+++ php-src/ext/libxml/libxml.c Sun Jul 18 07:45:12 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.18 2004/05/31 11:20:46 rrichards Exp $ */
+/* $Id: libxml.c,v 1.19 2004/07/18 11:45:12 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -568,7 +568,7 @@
obj_node = (php_libxml_node_ptr *) object-node;
ret_refcount = --obj_node-refcount;
if (ret_refcount == 0) {
-   if (obj_node-node != NULL  obj_node-node-type != 
XML_DOCUMENT_NODE) {
+   if (obj_node-node != NULL) {
obj_node-node-_private = NULL;
}
efree(obj_node);

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-05-31 Thread Rob Richards
rrichards   Mon May 31 07:20:46 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  fix leak when using relaxng
  interim fix for isolating our streams handling
  - once libxml supports overriding streams this should be changed
for security reasons
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.17r2=1.18ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.17 php-src/ext/libxml/libxml.c:1.18
--- php-src/ext/libxml/libxml.c:1.17Fri Apr 23 13:31:44 2004
+++ php-src/ext/libxml/libxml.c Mon May 31 07:20:46 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.17 2004/04/23 17:31:44 rrichards Exp $ */
+/* $Id: libxml.c,v 1.18 2004/05/31 11:20:46 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -40,6 +40,9 @@
 #include libxml/tree.h
 #include libxml/uri.h
 #include libxml/xmlerror.h
+#ifdef LIBXML_SCHEMAS_ENABLED
+#include libxml/relaxng.h
+#endif
 
 #include php_libxml.h
 
@@ -241,7 +244,11 @@
 int php_libxml_streams_IO_match_wrapper(const char *filename)
 {
TSRMLS_FETCH();
-   return php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC) ? 1 : 0;
+
+   if (zend_is_executing(TSRMLS_C)) {
+   return php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC) ? 1 
: 0;
+   }
+   return 0;
 }
 
 void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, 
const int read_only)
@@ -408,6 +415,9 @@
 
 PHP_LIBXML_API void php_libxml_shutdown() {
if (_php_libxml_initialized) {
+#if defined(LIBXML_SCHEMAS_ENABLED)
+   xmlRelaxNGCleanupTypes();
+#endif
xmlCleanupParser();
zend_hash_destroy(php_libxml_exports);
_php_libxml_initialized = 0;

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2004-04-23 Thread Rob Richards
rrichards   Fri Apr 23 13:31:45 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  move libxml error handler ro rinit/rshutdown to keep it local to php
  
http://cvs.php.net/diff.php/php-src/ext/libxml/libxml.c?r1=1.16r2=1.17ty=u
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.16 php-src/ext/libxml/libxml.c:1.17
--- php-src/ext/libxml/libxml.c:1.16Mon Mar  1 07:09:22 2004
+++ php-src/ext/libxml/libxml.c Fri Apr 23 13:31:44 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.16 2004/03/01 12:09:22 rrichards Exp $ */
+/* $Id: libxml.c,v 1.17 2004/04/23 17:31:44 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -400,9 +400,6 @@
php_libxml_streams_IO_write, 
php_libxml_streams_IO_close);
 
-   /* report errors via handler rather than stderr */
-   xmlSetGenericErrorFunc(NULL, php_libxml_error_handler);
-
zend_hash_init(php_libxml_exports, 0, NULL, NULL, 1);
 
_php_libxml_initialized = 1;
@@ -411,8 +408,6 @@
 
 PHP_LIBXML_API void php_libxml_shutdown() {
if (_php_libxml_initialized) {
-   /* reset libxml generic error handling */
-   xmlSetGenericErrorFunc(NULL, NULL);
xmlCleanupParser();
zend_hash_destroy(php_libxml_exports);
_php_libxml_initialized = 0;
@@ -436,6 +431,9 @@
 
 PHP_RINIT_FUNCTION(libxml)
 {
+   /* report errors via handler rather than stderr */
+   xmlSetGenericErrorFunc(NULL, php_libxml_error_handler);
+
 return SUCCESS;
 }
 
@@ -450,6 +448,9 @@
 
 PHP_RSHUTDOWN_FUNCTION(libxml)
 {
+   /* reset libxml generic error handling */
+   xmlSetGenericErrorFunc(NULL, NULL);
+
smart_str_free(LIBXML(error_buffer));
return SUCCESS;
 }

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2004-01-10 Thread Marcus Boerger
helly   Sat Jan 10 08:23:59 2004 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  Fix memory corruption with libxml's error handling.
  
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.13 php-src/ext/libxml/libxml.c:1.14
--- php-src/ext/libxml/libxml.c:1.13Thu Jan  8 03:15:56 2004
+++ php-src/ext/libxml/libxml.c Sat Jan 10 08:23:58 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.13 2004/01/08 08:15:56 andi Exp $ */
+/* $Id: libxml.c,v 1.14 2004/01/10 13:23:58 helly Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -225,7 +225,7 @@
 static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_DC)
 {
LIBXML(stream_context) = NULL;
-   LIBXML(error_buffer) = NULL;
+   LIBXML(error_buffer).c = NULL;
 }
 #endif
 
@@ -336,16 +336,15 @@
if (output == 1) {
switch (error_type) {
case PHP_LIBXML_CTX_ERROR:
-   php_libxml_ctx_error_level(E_WARNING, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+   php_libxml_ctx_error_level(E_WARNING, ctx, 
LIBXML(error_buffer).c TSRMLS_CC);
break;
case PHP_LIBXML_CTX_WARNING:
-   php_libxml_ctx_error_level(E_NOTICE, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+   php_libxml_ctx_error_level(E_NOTICE, ctx, 
LIBXML(error_buffer).c TSRMLS_CC);
break;
default:
-   php_error(E_WARNING, %s, (char *) 
LIBXML(error_buffer));
+   php_error(E_WARNING, %s, LIBXML(error_buffer).c);
}
smart_str_free(LIBXML(error_buffer));
-   LIBXML(error_buffer) = NULL;
}
 }
 
@@ -419,7 +418,7 @@
ts_allocate_id(libxml_globals_id, sizeof(php_libxml_globals), 
(ts_allocate_ctor) php_libxml_init_globals, NULL);
 #else
LIBXML(stream_context) = NULL;
-   LIBXML(error_buffer) = NULL;
+   LIBXML(error_buffer).c = NULL;
 #endif
 
return SUCCESS;
@@ -441,10 +440,7 @@
 
 PHP_RSHUTDOWN_FUNCTION(libxml)
 {
-   if (LIBXML(error_buffer)) {
-   smart_str_free(LIBXML(error_buffer));
-   LIBXML(error_buffer) = NULL;
-   }
+   smart_str_free(LIBXML(error_buffer));
return SUCCESS;
 }
 
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.6 php-src/ext/libxml/php_libxml.h:1.7
--- php-src/ext/libxml/php_libxml.h:1.6 Thu Jan  8 12:32:20 2004
+++ php-src/ext/libxml/php_libxml.h Sat Jan 10 08:23:58 2004
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.6 2004/01/08 17:32:20 sniper Exp $ */
+/* $Id: php_libxml.h,v 1.7 2004/01/10 13:23:58 helly Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -42,7 +42,7 @@
 
 typedef struct {
zval *stream_context;
-   smart_str *error_buffer;
+   smart_str error_buffer;
 } php_libxml_globals;
 
 typedef struct _php_libxml_ref_obj {

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-12-22 Thread Rob Richards
rrichards   Mon Dec 22 11:46:26 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  only test url_stat in read mode
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.11 php-src/ext/libxml/libxml.c:1.12
--- php-src/ext/libxml/libxml.c:1.11Fri Dec 12 08:54:06 2003
+++ php-src/ext/libxml/libxml.c Mon Dec 22 11:46:26 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.11 2003/12/12 13:54:06 rrichards Exp $ */
+/* $Id: libxml.c,v 1.12 2003/12/22 16:46:26 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -238,7 +238,7 @@
return php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC) ? 1 : 0;
 }
 
-void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode)
+void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, 
const int read_only)
 {
char resolved_path[MAXPATHLEN + 1];
php_stream_statbuf ssbuf;
@@ -257,7 +257,7 @@
   may try to open files that don't exist, but it is not a failure
   in xml processing (eg. DTD files)  */
wrapper = php_stream_locate_url_wrapper(resolved_path, path_to_open, 
ENFORCE_SAFE_MODE TSRMLS_CC);
-   if (wrapper  wrapper-wops-url_stat) {
+   if (wrapper  read_only  wrapper-wops-url_stat) {
if (wrapper-wops-url_stat(wrapper, path_to_open, 0, ssbuf, NULL 
TSRMLS_CC) == -1) {
return NULL;
}
@@ -272,12 +272,12 @@
 
 void *php_libxml_streams_IO_open_read_wrapper(const char *filename)
 {
-   return php_libxml_streams_IO_open_wrapper(filename, rb);
+   return php_libxml_streams_IO_open_wrapper(filename, rb, 1);
 }
 
 void *php_libxml_streams_IO_open_write_wrapper(const char *filename)
 {
-   return php_libxml_streams_IO_open_wrapper(filename, wb);
+   return php_libxml_streams_IO_open_wrapper(filename, wb, 0);
 }
 
 int php_libxml_streams_IO_read(void *context, char *buffer, int len)

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2003-12-12 Thread Rob Richards
rrichards   Fri Dec 12 08:54:07 2003 EDT

  Modified files:  
/php-src/ext/libxml php_libxml.h libxml.c 
  Log:
  consolidate error handling
  
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.4 php-src/ext/libxml/php_libxml.h:1.5
--- php-src/ext/libxml/php_libxml.h:1.4 Tue Dec  9 16:55:02 2003
+++ php-src/ext/libxml/php_libxml.h Fri Dec 12 08:54:06 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.4 2003/12/09 21:55:02 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.5 2003/12/12 13:54:06 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -73,6 +73,9 @@
 void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
 /* When object dtor is called as node may still be referenced */
 void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
+void php_libxml_error_handler(void *ctx, const char *msg, ...);
+void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
+void php_libxml_ctx_error(void *ctx, const char *msg, ...);
 
 #endif /* HAVE_LIBXML */
 
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.10 php-src/ext/libxml/libxml.c:1.11
--- php-src/ext/libxml/libxml.c:1.10Tue Dec  9 16:55:02 2003
+++ php-src/ext/libxml/libxml.c Fri Dec 12 08:54:06 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.10 2003/12/09 21:55:02 rrichards Exp $ */
+/* $Id: libxml.c,v 1.11 2003/12/12 13:54:06 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -43,6 +43,10 @@
 
 #include php_libxml.h
 
+#define PHP_LIBXML_ERROR 0
+#define PHP_LIBXML_CTX_ERROR 1
+#define PHP_LIBXML_CTX_WARNING 2
+
 /* a true global for initialization */
 int _php_libxml_initialized = 0;
 
@@ -294,22 +298,33 @@
return php_stream_close((php_stream*)context);
 }
 
-static void php_libxml_error_handler(void *ctx, const char *msg, ...)
+static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg 
TSRMLS_DC)
+{
+   xmlParserCtxtPtr parser;
+
+   parser = (xmlParserCtxtPtr) ctx;
+
+   if (parser != NULL  parser-input != NULL) {
+   if (parser-input-filename) {
+   php_error_docref(NULL TSRMLS_CC, level, %s in %s, line: %d, 
msg, parser-input-filename, parser-input-line);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, level, %s in Entity, line: 
%d, msg, parser-input-line);
+   }
+   }
+}
+
+static void php_libxml_internal_error_handler(int error_type, void *ctx, const char 
**msg, va_list ap)
 {
-   va_list ap;
char *buf;
int len, len_iter, output = 0;
 
TSRMLS_FETCH();
 
-   va_start(ap, msg);
-   len = vspprintf(buf, 0, msg, ap);
-   va_end(ap);
-
+   len = vspprintf(buf, 0, *msg, ap);
len_iter = len;
 
/* remove any trailing \n */
-   while (len  buf[--len_iter] == '\n') {
+   while (len_iter  buf[--len_iter] == '\n') {
buf[len_iter] = '\0';
output = 1;
}
@@ -319,12 +334,46 @@
efree(buf);
 
if (output == 1) {
-   php_error(E_WARNING, %s, (char *) LIBXML(error_buffer));
+   switch (error_type) {
+   case PHP_LIBXML_CTX_ERROR:
+   php_libxml_ctx_error_level(E_WARNING, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+   break;
+   case PHP_LIBXML_CTX_WARNING:
+   php_libxml_ctx_error_level(E_NOTICE, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+   break;
+   default:
+   php_error(E_WARNING, %s, (char *) 
LIBXML(error_buffer));
+   }
smart_str_free(LIBXML(error_buffer));
LIBXML(error_buffer) = NULL;
}
 }
 
+void php_libxml_ctx_error(void *ctx, const char *msg, ...)
+{
+   va_list args;
+   va_start(args, msg);
+   php_libxml_internal_error_handler(PHP_LIBXML_CTX_ERROR, ctx, msg, args);
+   va_end(args);
+}
+
+void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
+{
+   va_list args;
+   va_start(args, msg);
+   php_libxml_internal_error_handler(PHP_LIBXML_CTX_WARNING, ctx, msg, args);
+   va_end(args);
+}
+
+void php_libxml_error_handler(void *ctx, const char *msg, ...)
+{
+   va_list args;
+   va_start(args, msg);
+   php_libxml_internal_error_handler(PHP_LIBXML_ERROR, ctx, msg, args);
+   va_end(args);
+}
+
+
 PHP_LIBXML_API void php_libxml_initialize() {
if (!_php_libxml_initialized) {
/* we should be the only one's to ever init!! */

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2003-12-09 Thread Rob Richards
rrichards   Tue Dec  9 16:55:03 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  buffer error messages until newline is hit
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.9 php-src/ext/libxml/libxml.c:1.10
--- php-src/ext/libxml/libxml.c:1.9 Fri Nov 28 18:25:25 2003
+++ php-src/ext/libxml/libxml.c Tue Dec  9 16:55:02 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.9 2003/11/28 23:25:25 pollita Exp $ */
+/* $Id: libxml.c,v 1.10 2003/12/09 21:55:02 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -221,6 +221,7 @@
 static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_DC)
 {
LIBXML(stream_context) = NULL;
+   LIBXML(error_buffer) = NULL;
 }
 #endif
 
@@ -297,19 +298,31 @@
 {
va_list ap;
char *buf;
-   int len;
+   int len, len_iter, output = 0;
+
+   TSRMLS_FETCH();
 
va_start(ap, msg);
len = vspprintf(buf, 0, msg, ap);
va_end(ap);
-   
+
+   len_iter = len;
+
/* remove any trailing \n */
-   while (len  buf[--len] == '\n') {
-   buf[len] = '\0';
+   while (len  buf[--len_iter] == '\n') {
+   buf[len_iter] = '\0';
+   output = 1;
}
 
-   php_error(E_WARNING, %s, buf);
+   smart_str_appendl(LIBXML(error_buffer), buf, len);
+
efree(buf);
+
+   if (output == 1) {
+   php_error(E_WARNING, %s, (char *) LIBXML(error_buffer));
+   smart_str_free(LIBXML(error_buffer));
+   LIBXML(error_buffer) = NULL;
+   }
 }
 
 PHP_LIBXML_API void php_libxml_initialize() {
@@ -357,6 +370,7 @@
ts_allocate_id(libxml_globals_id, sizeof(php_libxml_globals), 
(ts_allocate_ctor) php_libxml_init_globals, NULL);
 #else
LIBXML(stream_context) = NULL;
+   LIBXML(error_buffer) = NULL;
 #endif
 
return SUCCESS;
@@ -378,6 +392,10 @@
 
 PHP_RSHUTDOWN_FUNCTION(libxml)
 {
+   if (LIBXML(error_buffer)) {
+   smart_str_free(LIBXML(error_buffer));
+   LIBXML(error_buffer) = NULL;
+   }
return SUCCESS;
 }
 
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.3 php-src/ext/libxml/php_libxml.h:1.4
--- php-src/ext/libxml/php_libxml.h:1.3 Sun Oct 26 10:53:20 2003
+++ php-src/ext/libxml/php_libxml.h Tue Dec  9 16:55:02 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_libxml.h,v 1.3 2003/10/26 15:53:20 rrichards Exp $ */
+/* $Id: php_libxml.h,v 1.4 2003/12/09 21:55:02 rrichards Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -37,10 +37,12 @@
 #define PHP_LIBXML_API
 #endif
 
+#include ext/standard/php_smart_str.h
 #include libxml/tree.h
 
 typedef struct {
zval *stream_context;
+   smart_str *error_buffer;
 } php_libxml_globals;
 
 typedef struct _php_libxml_ref_obj {

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-11-07 Thread Ilia Alshanetsky
iliaa   Fri Nov  7 14:12:46 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fixed write support.
  
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.7 php-src/ext/libxml/libxml.c:1.8
--- php-src/ext/libxml/libxml.c:1.7 Sun Oct 26 10:53:20 2003
+++ php-src/ext/libxml/libxml.c Fri Nov  7 14:12:46 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.7 2003/10/26 15:53:20 rrichards Exp $ */
+/* $Id: libxml.c,v 1.8 2003/11/07 19:12:46 iliaa Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -233,7 +233,7 @@
return php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC) ? 1 : 0;
 }
 
-void *php_libxml_streams_IO_open_wrapper(const char *filename)
+void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode)
 {
char resolved_path[MAXPATHLEN + 1];
php_stream_statbuf ssbuf;
@@ -260,9 +260,19 @@
 
if (LIBXML(stream_context)) {
context = zend_fetch_resource(LIBXML(stream_context) TSRMLS_CC, -1, 
Stream-Context, NULL, 1, php_le_stream_context());
-   return php_stream_open_wrapper_ex((char *)resolved_path, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
+   return php_stream_open_wrapper_ex((char *)resolved_path, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
}
-   return php_stream_open_wrapper((char *)resolved_path, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+   return php_stream_open_wrapper((char *)resolved_path, (char *)mode, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+}
+
+void *php_libxml_streams_IO_open_read_wrapper(const char *filename)
+{
+   return php_libxml_streams_IO_open_wrapper(filename, rb);
+}
+
+void *php_libxml_streams_IO_open_write_wrapper(const char *filename)
+{
+   return php_libxml_streams_IO_open_wrapper(filename, wb);
 }
 
 int php_libxml_streams_IO_read(void *context, char *buffer, int len)
@@ -313,13 +323,13 @@
*/
xmlRegisterInputCallbacks(
php_libxml_streams_IO_match_wrapper, 
-   php_libxml_streams_IO_open_wrapper,
+   php_libxml_streams_IO_open_read_wrapper,
php_libxml_streams_IO_read, 
php_libxml_streams_IO_close);
 
xmlRegisterOutputCallbacks(
php_libxml_streams_IO_match_wrapper, 
-   php_libxml_streams_IO_open_wrapper,
+   php_libxml_streams_IO_open_write_wrapper,
php_libxml_streams_IO_write, 
php_libxml_streams_IO_close);
 

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c php_libxml.h

2003-10-26 Thread Rob Richards
rrichards   Sun Oct 26 10:53:20 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  common functions for interoperability
  Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.6 php-src/ext/libxml/libxml.c:1.7
--- php-src/ext/libxml/libxml.c:1.6 Mon Oct 20 11:33:40 2003
+++ php-src/ext/libxml/libxml.c Sun Oct 26 10:53:20 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.6 2003/10/20 15:33:40 moriyoshi Exp $ */
+/* $Id: libxml.c,v 1.7 2003/10/26 15:53:20 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -91,6 +91,131 @@
 
 /* }}} */
 
+/* {{{ internal functions for interoperability */
+static int php_libxml_dec_node(php_libxml_node_ptr *nodeptr)
+{
+   int ret_refcount;
+
+   ret_refcount = --nodeptr-refcount;
+   if (ret_refcount == 0) {
+   if (nodeptr-node != NULL  nodeptr-node-type != XML_DOCUMENT_NODE) 
{
+   nodeptr-node-_private = NULL;
+   }
+   /* node is destroyed by another object. reset ret_refcount to 1 and 
node to NULL
+   so the php_libxml_node_ptr is detroyed when the object is destroyed */
+   nodeptr-refcount = 1;
+   nodeptr-node = NULL;
+   }
+
+   return ret_refcount;
+}
+
+static int php_libxml_clear_object(php_libxml_node_object *object TSRMLS_DC)
+{
+   if (object-properties) {
+   object-properties = NULL;
+   }
+   php_libxml_decrement_node_ptr(object TSRMLS_CC);
+   return php_libxml_decrement_doc_ref(object TSRMLS_CC);
+}
+
+static int php_libxml_unregister_node(xmlNodePtr nodep TSRMLS_DC)
+{
+   php_libxml_node_object *wrapper;
+
+   php_libxml_node_ptr *nodeptr = nodep-_private;
+
+   if (nodeptr != NULL) {
+   wrapper = nodeptr-_private;
+   if (wrapper) {
+   php_libxml_clear_object(wrapper TSRMLS_CC);
+   } else {
+   php_libxml_dec_node(nodeptr);
+   }
+   }
+
+   return -1;
+}
+
+static void php_libxml_node_free(xmlNodePtr node)
+{
+   if(node) {
+   if (node-_private != NULL) {
+   ((php_libxml_node_ptr *) node-_private)-node = NULL;
+   }
+   switch (node-type) {
+   case XML_ATTRIBUTE_NODE:
+   xmlFreeProp((xmlAttrPtr) node);
+   break;
+   case XML_ENTITY_DECL:
+   case XML_ELEMENT_DECL:
+   case XML_ATTRIBUTE_DECL:
+   break;
+   case XML_NOTATION_NODE:
+   /* These require special handling */
+   if (node-name != NULL) {
+   xmlFree((char *) node-name);
+   }
+   if (((xmlEntityPtr) node)-ExternalID != NULL) {
+   xmlFree((char *) ((xmlEntityPtr) 
node)-ExternalID);
+   }
+   if (((xmlEntityPtr) node)-SystemID != NULL) {
+   xmlFree((char *) ((xmlEntityPtr) 
node)-SystemID);
+   }
+   xmlFree(node);
+   break;
+   case XML_NAMESPACE_DECL:
+   if (node-ns) {
+   xmlFreeNs(node-ns);
+   node-ns = NULL;
+   }
+   node-type = XML_ELEMENT_NODE;
+   default:
+   xmlFreeNode(node);
+   }
+   }
+}
+
+static void php_libxml_node_free_list(xmlNodePtr node TSRMLS_DC)
+{
+   xmlNodePtr curnode;
+
+   if (node != NULL) {
+   curnode = node;
+   while (curnode != NULL) {
+   node = curnode;
+   switch (node-type) {
+   /* Skip property freeing for the following types */
+   case XML_NOTATION_NODE:
+   break;
+   case XML_ENTITY_REF_NODE:
+   php_libxml_node_free_list((xmlNodePtr) 
node-properties TSRMLS_CC);
+   break;
+   case XML_ATTRIBUTE_DECL:
+   case XML_DTD_NODE:
+   case XML_DOCUMENT_TYPE_NODE:
+   case XML_ENTITY_DECL:
+   case XML_ATTRIBUTE_NODE:
+   case XML_NAMESPACE_DECL:
+   

[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-10-20 Thread Moriyoshi Koizumi
moriyoshi   Mon Oct 20 11:33:41 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  Fix compiler warnings
  
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.5 php-src/ext/libxml/libxml.c:1.6
--- php-src/ext/libxml/libxml.c:1.5 Sun Oct 19 23:11:45 2003
+++ php-src/ext/libxml/libxml.c Mon Oct 20 11:33:40 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.5 2003/10/20 03:11:45 shane Exp $ */
+/* $Id: libxml.c,v 1.6 2003/10/20 15:33:40 moriyoshi Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -31,6 +31,7 @@
 #include zend_variables.h
 #include ext/standard/php_string.h
 #include ext/standard/info.h
+#include ext/standard/file.h
 
 #if HAVE_LIBXML
 
@@ -110,7 +111,6 @@
 void *php_libxml_streams_IO_open_wrapper(const char *filename)
 {
char resolved_path[MAXPATHLEN + 1];
-   int file_exist;
php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
php_stream_wrapper *wrapper = NULL;

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-10-19 Thread Rob Richards
rrichards   Sun Oct 19 19:25:49 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  unescape filepath which libxml excapes
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.2 php-src/ext/libxml/libxml.c:1.3
--- php-src/ext/libxml/libxml.c:1.2 Sun Oct 19 19:17:56 2003
+++ php-src/ext/libxml/libxml.c Sun Oct 19 19:25:48 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.2 2003/10/19 23:17:56 shane Exp $ */
+/* $Id: libxml.c,v 1.3 2003/10/19 23:25:48 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -109,13 +109,23 @@
 
 void *php_libxml_streams_IO_open_wrapper(const char *filename)
 {
+   char resolved_path[MAXPATHLEN + 1];
+   int file_exist;
+   php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
+
TSRMLS_FETCH();
+   xmlURIUnescapeString(filename, 0, resolved_path);
+   file_exist = _php_stream_stat_path((char *) resolved_path, ssbuf TSRMLS_CC);
+   if (file_exist == -1) {
+   return NULL;
+   }
+
if (LIBXML(stream_context)) {
context = zend_fetch_resource(LIBXML(stream_context) TSRMLS_CC, -1, 
Stream-Context, NULL, 1, php_le_stream_context());
-   return php_stream_open_wrapper_ex((char *)filename, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
+   return php_stream_open_wrapper_ex((char *)resolved_path, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
}
-   return php_stream_open_wrapper((char *)filename, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+   return php_stream_open_wrapper((char *)resolved_path, rb, 
ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
 }
 
 int php_libxml_streams_IO_read(void *context, char *buffer, int len)

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-10-19 Thread Rob Richards
rrichards   Sun Oct 19 19:34:40 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  add generic default error handling rather than the default stderr
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.3 php-src/ext/libxml/libxml.c:1.4
--- php-src/ext/libxml/libxml.c:1.3 Sun Oct 19 19:25:48 2003
+++ php-src/ext/libxml/libxml.c Sun Oct 19 19:34:39 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.3 2003/10/19 23:25:48 rrichards Exp $ */
+/* $Id: libxml.c,v 1.4 2003/10/19 23:34:39 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -146,6 +146,25 @@
return php_stream_close((php_stream*)context);
 }
 
+static void php_libxml_error_handler(void *ctx, const char *msg, ...)
+{
+   va_list ap;
+   char *buf;
+   int len;
+
+   va_start(ap, msg);
+   len = vspprintf(buf, 0, msg, ap);
+   va_end(ap);
+   
+   /* remove any trailing \n */
+   while (len  buf[--len] == '\n') {
+   buf[len] = '\0';
+   }
+
+   php_error(E_WARNING, %s, buf);
+   efree(buf);
+}
+
 PHP_LIBXML_API void php_libxml_initialize() {
if (!_php_libxml_initialized) {
/* we should be the only one's to ever init!! */
@@ -167,12 +186,17 @@
php_libxml_streams_IO_write, 
php_libxml_streams_IO_close);
 
+   /* report errors via handler rather than stderr */
+   xmlSetGenericErrorFunc(NULL, php_libxml_error_handler);
+
_php_libxml_initialized = 1;
}
 }
 
 PHP_LIBXML_API void php_libxml_shutdown() {
if (_php_libxml_initialized) {
+   /* reset libxml generic error handling */
+   xmlSetGenericErrorFunc(NULL, NULL);
xmlCleanupParser();
_php_libxml_initialized = 0;
}

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



[PHP-CVS] cvs: php-src /ext/libxml libxml.c

2003-10-19 Thread Shane Caraveo
shane   Sun Oct 19 23:11:46 2003 EDT

  Modified files:  
/php-src/ext/libxml libxml.c 
  Log:
  fix the stat check in stream open
  addref to the stream context
  
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.4 php-src/ext/libxml/libxml.c:1.5
--- php-src/ext/libxml/libxml.c:1.4 Sun Oct 19 19:34:39 2003
+++ php-src/ext/libxml/libxml.c Sun Oct 19 23:11:45 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: libxml.c,v 1.4 2003/10/19 23:34:39 rrichards Exp $ */
+/* $Id: libxml.c,v 1.5 2003/10/20 03:11:45 shane Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -113,12 +113,24 @@
int file_exist;
php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
+   php_stream_wrapper *wrapper = NULL;
+   char *path_to_open = NULL;
 
TSRMLS_FETCH();
xmlURIUnescapeString(filename, 0, resolved_path);
-   file_exist = _php_stream_stat_path((char *) resolved_path, ssbuf TSRMLS_CC);
-   if (file_exist == -1) {
-   return NULL;
+   path_to_open = resolved_path;
+
+   /* logic copied from _php_stream_stat, but we only want to fail
+  if the wrapper supports stat, otherwise, figure it out from
+  the open.  This logic is only to support hiding warnings
+  that the streams layer puts out at times, but for libxml we
+  may try to open files that don't exist, but it is not a failure
+  in xml processing (eg. DTD files)  */
+   wrapper = php_stream_locate_url_wrapper(resolved_path, path_to_open, 
ENFORCE_SAFE_MODE TSRMLS_CC);
+   if (wrapper  wrapper-wops-url_stat) {
+   if (wrapper-wops-url_stat(wrapper, path_to_open, ssbuf TSRMLS_CC) 
== -1) {
+   return NULL;
+   }
}
 
if (LIBXML(stream_context)) {
@@ -255,6 +267,11 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z, arg) == FAILURE) {
return;
}
+   if (LIBXML(stream_context)) {
+   ZVAL_DELREF(LIBXML(stream_context));
+   LIBXML(stream_context) = NULL;
+   }
+   ZVAL_ADDREF(arg);
LIBXML(stream_context) = arg;
 }
 /* }}} */

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