rrichards Mon Sep 29 07:43:27 2003 EDT Modified files: /php-src/ext/dom xpath.c php_dom.c characterdata.c Log: add property_get_ptr handler fix possible segfault in xpath add wide character support for characterdata Index: php-src/ext/dom/xpath.c diff -u php-src/ext/dom/xpath.c:1.4 php-src/ext/dom/xpath.c:1.5 --- php-src/ext/dom/xpath.c:1.4 Mon Sep 8 14:28:35 2003 +++ php-src/ext/dom/xpath.c Mon Sep 29 07:43:26 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xpath.c,v 1.4 2003/09/08 18:28:35 rrichards Exp $ */ +/* $Id: xpath.c,v 1.5 2003/09/29 11:43:26 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -169,7 +169,7 @@ nodep = xmlDocGetRootElement(docp); } - if (docp != nodep->doc) { + if (nodep && docp != nodep->doc) { php_error(E_WARNING, "Node From Wrong Document"); RETURN_FALSE; } Index: php-src/ext/dom/php_dom.c diff -u php-src/ext/dom/php_dom.c:1.32 php-src/ext/dom/php_dom.c:1.33 --- php-src/ext/dom/php_dom.c:1.32 Mon Sep 8 14:28:35 2003 +++ php-src/ext/dom/php_dom.c Mon Sep 29 07:43:26 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dom.c,v 1.32 2003/09/08 18:28:35 rrichards Exp $ */ +/* $Id: php_dom.c,v 1.33 2003/09/29 11:43:26 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -405,6 +405,17 @@ } /* }}} */ +static zval **dom_property_get_ptr(zval *object, zval *member TSRMLS_DC) +{ + zval **prop_ptr; + zval *property; + + property = dom_read_property(object, member, 0 TSRMLS_CC); + prop_ptr = &property; + + return prop_ptr; +} + zend_module_entry dom_module_entry = { STANDARD_MODULE_HEADER, "dom", @@ -430,6 +441,7 @@ memcpy(&dom_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); dom_object_handlers.read_property = dom_read_property; dom_object_handlers.write_property = dom_write_property; + dom_object_handlers.get_property_ptr = dom_property_get_ptr; zend_hash_init(&classes, 0, NULL, NULL, 1); Index: php-src/ext/dom/characterdata.c diff -u php-src/ext/dom/characterdata.c:1.8 php-src/ext/dom/characterdata.c:1.9 --- php-src/ext/dom/characterdata.c:1.8 Sun Aug 24 06:23:43 2003 +++ php-src/ext/dom/characterdata.c Mon Sep 29 07:43:26 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: characterdata.c,v 1.8 2003/08/24 10:23:43 rrichards Exp $ */ +/* $Id: characterdata.c,v 1.9 2003/09/29 11:43:26 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -80,20 +80,6 @@ /* }}} */ - -long dom_utf16Length (xmlChar *utf8str) { - long len = 0L, i; - char c; - - for (i = 0L; (c = utf8str[i]) != '\0'; i++) - if ((c & 0xf8) == 0xf0) - len += 2L; - else if ((c & 0xc0) != 0x80) - len++; - - return len; -} - /* {{{ proto length unsigned long readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7D61178C @@ -110,7 +96,8 @@ ALLOC_ZVAL(*retval); content = xmlNodeGetContent(nodep); - length = dom_utf16Length(content); + length = xmlUTF8Strlen(content); + xmlFree(content); ZVAL_LONG(*retval, length); @@ -146,7 +133,7 @@ RETURN_FALSE; } - length = xmlStrlen(cur); + length = xmlUTF8Strlen(cur); if (offset < 0 || count < 0 || offset > length) { xmlFree(cur); @@ -158,7 +145,7 @@ count = length - offset; } - substring = xmlStrsub(cur, offset, count); + substring = xmlUTF8Strsub(cur, offset, count); xmlFree(cur); if (substring) { @@ -221,7 +208,7 @@ RETURN_FALSE; } - length = xmlStrlen(cur); + length = xmlUTF8Strlen(cur); if (offset < 0 || offset > length) { xmlFree(cur); @@ -229,8 +216,8 @@ RETURN_FALSE; } - first = xmlStrndup(cur, offset); - second = xmlStrdup(cur + offset); + first = xmlUTF8Strndup(cur, offset); + second = xmlUTF8Strsub(cur, offset, length - offset); xmlFree(cur); xmlNodeSetContent(node, first); @@ -268,7 +255,7 @@ RETURN_FALSE; } - length = xmlStrlen(cur); + length = xmlUTF8Strlen(cur); if (offset < 0 || count < 0 || offset > length) { xmlFree(cur); @@ -277,7 +264,7 @@ } if (offset > 0) { - substring = xmlStrsub(cur, 0, offset); + substring = xmlUTF8Strsub(cur, 0, offset); } else { substring = NULL; } @@ -286,7 +273,7 @@ count = length - offset; } - second = xmlStrdup(cur + offset + count); + second = xmlUTF8Strsub(cur, offset + count, length - offset); substring = xmlStrcat(substring, second); xmlNodeSetContent(node, substring); @@ -324,7 +311,7 @@ RETURN_FALSE; } - length = xmlStrlen(cur); + length = xmlUTF8Strlen(cur); if (offset < 0 || count < 0 || offset > length) { xmlFree(cur); @@ -333,17 +320,17 @@ } if (offset > 0) { - substring = xmlStrsub(cur, 0, offset); + substring = xmlUTF8Strsub(cur, 0, offset); } else { substring = NULL; } if ((offset + count) > length) { - count = 0; + count = length - offset; } if (offset < length) { - second = xmlStrdup(cur + offset + count); + second = xmlUTF8Strsub(cur, offset + count, length - offset); } substring = xmlStrcat(substring, arg);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php