Re: [PHP-CVS] cvs: php-src /ext/xml compat.c xml.c
Excellent! This was great fix! Thanks! (not that any of my code dependended upon it, just the joy of getting long outstanding bug fixed finally :) --Jani On Wed, 12 Oct 2005, Rob Richards wrote: rrichards Tue Oct 11 23:20:14 2005 EDT Modified files: /php-src/ext/xml compat.c xml.c Log: Fixed Bug #27908 (xml default_handlers not being called) Fix memleak when entitydecls are parsed remove old ifdefs -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/xml compat.c xml.c
rrichards Tue Oct 11 23:20:14 2005 EDT Modified files: /php-src/ext/xmlcompat.c xml.c Log: Fixed Bug #27908 (xml default_handlers not being called) Fix memleak when entitydecls are parsed remove old ifdefs http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.44r2=1.45ty=u Index: php-src/ext/xml/compat.c diff -u php-src/ext/xml/compat.c:1.44 php-src/ext/xml/compat.c:1.45 --- php-src/ext/xml/compat.c:1.44 Wed Aug 3 10:08:21 2005 +++ php-src/ext/xml/compat.cTue Oct 11 23:20:13 2005 @@ -33,7 +33,6 @@ ((__ns) != NULL strlen(__ns) == 5 *(__ns) == 'x' *((__ns)+1) == 'm' \ *((__ns)+2) == 'l' *((__ns)+3) == 'n' *((__ns)+4) == 's') -#if LIBXML_VERSION = 20600 static void _qualify_namespace(XML_Parser parser, const xmlChar *name, const xmlChar *URI, xmlChar **qualified) { @@ -46,7 +45,6 @@ *qualified = xmlStrdup(name); } } -#endif static void _start_element_handler(void *user, const xmlChar *name, const xmlChar **attributes) @@ -55,6 +53,25 @@ xmlChar*qualified_name = NULL; if (parser-h_start_element == NULL) { + if (parser-h_default) { + int attno = 0; + + qualified_name = xmlStrncatNew((xmlChar *), name, xmlStrlen(name)); + if (attributes) { + while (attributes[attno] != NULL) { + qualified_name = xmlStrncat(qualified_name, (xmlChar *) , 1); + qualified_name = xmlStrcat(qualified_name, (xmlChar *)attributes[attno]); + qualified_name = xmlStrncat(qualified_name, (xmlChar *)=\, 2); + qualified_name = xmlStrcat(qualified_name, (xmlChar *)attributes[++attno]); + qualified_name = xmlStrncat(qualified_name, (xmlChar *)\, 1); + attno++; + } + + } + qualified_name = xmlStrncat(qualified_name, (xmlChar *), 1); + parser-h_default(parser-user, (const XML_Char *) qualified_name, xmlStrlen(qualified_name)); + xmlFree(qualified_name); + } return; } @@ -65,7 +82,6 @@ xmlFree(qualified_name); } -#if LIBXML_VERSION = 20600 static void _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes) { @@ -84,7 +100,7 @@ y = 0; } - if (parser-h_start_element == NULL) { + if (parser-h_start_element == NULL parser-h_default == NULL) { return; } _qualify_namespace(parser, name, URI, qualified_name); @@ -117,7 +133,6 @@ } xmlFree(qualified_name); } -#endif static void _namespace_handler(XML_Parser parser, xmlNsPtr nsptr) @@ -135,6 +150,12 @@ XML_Parser parser = (XML_Parser) user; if (parser-h_end_element == NULL) { + if (parser-h_default) { + qualified_name = xmlStrncatNew((xmlChar *)/, name, xmlStrlen(name)); + qualified_name = xmlStrncat(qualified_name, (xmlChar *), 1); + parser-h_default(parser-user, (const XML_Char *) qualified_name, xmlStrlen(qualified_name)); + xmlFree(qualified_name); + } return; } @@ -145,7 +166,6 @@ xmlFree(qualified_name); } -#if LIBXML_VERSION = 20600 static void _end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, const xmlChar *URI) { @@ -162,7 +182,6 @@ xmlFree(qualified_name); } -#endif static void _cdata_handler(void *user, const xmlChar *cdata, int cdata_len) @@ -170,6 +189,9 @@ XML_Parser parser = (XML_Parser) user; if (parser-h_cdata == NULL) { + if (parser-h_default) { + parser-h_default(parser-user, (const XML_Char *) cdata, cdata_len); + } return; } @@ -182,6 +204,16 @@ XML_Parser parser = (XML_Parser) user; if (parser-h_pi == NULL) { + if (parser-h_default) { + xmlChar*full_pi; + + full_pi = xmlStrncatNew((xmlChar *)?, target, xmlStrlen(target)); + full_pi = xmlStrncat(full_pi, (xmlChar *) , 1); + full_pi = xmlStrcat(full_pi, data); + full_pi = xmlStrncat(full_pi, (xmlChar *)?, 2); + parser-h_default(parser-user, (const XML_Char *) full_pi, xmlStrlen(full_pi)); + xmlFree(full_pi); +
[PHP-CVS] cvs: php-src /ext/xml compat.c xml.c
chregu Thu Aug 19 08:18:25 2004 EDT Modified files: /php-src/ext/xmlcompat.c xml.c Log: fix for bug #29657 xml_* functions throw non descriptive error, compared to php4 fix for bug #29711 libxml and non iso-8859-1. If no encoding specified, it defaults to UTF-8 now http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.32r2=1.33ty=u Index: php-src/ext/xml/compat.c diff -u php-src/ext/xml/compat.c:1.32 php-src/ext/xml/compat.c:1.33 --- php-src/ext/xml/compat.c:1.32 Wed Apr 7 12:24:17 2004 +++ php-src/ext/xml/compat.cThu Aug 19 08:18:25 2004 @@ -463,9 +463,9 @@ No error, Internal error, No memory, - XML_ERR_DOCUMENT_START, + Invalid document start, Empty document, - XML_ERR_DOCUMENT_END, + Invalid document end, Invalid hexadecimal character reference, Invalid decimal character reference, Invalid character reference, @@ -478,14 +478,14 @@ XML_ERR_ENTITYREF_IN_PROLOG, XML_ERR_ENTITYREF_IN_EPILOG, XML_ERR_ENTITYREF_IN_DTD, - XML_ERR_PEREF_AT_EOF, - XML_ERR_PEREF_IN_PROLOG, - XML_ERR_PEREF_IN_EPILOG, - XML_ERR_PEREF_IN_INT_SUBSET, + PEReference at end of document, + PEReference in prolog, + PEReference in epilog, + PEReference: forbidden within markup decl in internal subset, XML_ERR_ENTITYREF_NO_NAME, - XML_ERR_ENTITYREF_SEMICOL_MISSING, - XML_ERR_PEREF_NO_NAME, - XML_ERR_PEREF_SEMICOL_MISSING, + EntityRef: expecting ';', + PEReference: no name, + PEReference: expecting ';', Undeclared entity error, Undeclared entity warning, Unparsed Entity, @@ -493,82 +493,82 @@ XML_ERR_ENTITY_IS_PARAMETER, Unknown encoding, Unsupported encoding, - XML_ERR_STRING_NOT_STARTED, - XML_ERR_STRING_NOT_CLOSED, + String not started expecting ' or \, + String not closed expecting \ or ', Namespace declaration error, - XML_ERR_ENTITY_NOT_STARTED, - XML_ERR_ENTITY_NOT_FINISHED, - XML_ERR_LT_IN_ATTRIBUTE, - XML_ERR_ATTRIBUTE_NOT_STARTED, - XML_ERR_ATTRIBUTE_NOT_FINISHED, - XML_ERR_ATTRIBUTE_WITHOUT_VALUE, - XML_ERR_ATTRIBUTE_REDEFINED, - XML_ERR_LITERAL_NOT_STARTED, - XML_ERR_LITERAL_NOT_FINISHED, + EntityValue: \ or ' expected, + EntityValue: \ or ' expected, +in attribute, + Attribute not started, + Attribute not finished, + Attribute without value, + Attribute redefined, + SystemLiteral \ or ' expected, + SystemLiteral \ or ' expected, /* XML_ERR_COMMENT_NOT_STARTED, = eliminated on purpose */ - XML_ERR_COMMENT_NOT_FINISHED, - XML_ERR_PI_NOT_STARTED, - XML_ERR_PI_NOT_FINISHED, - XML_ERR_NOTATION_NOT_STARTED, - XML_ERR_NOTATION_NOT_FINISHED, - XML_ERR_ATTLIST_NOT_STARTED, - XML_ERR_ATTLIST_NOT_FINISHED, - XML_ERR_MIXED_NOT_STARTED, + Comment not finished, + Processing Instruction not started, + Processing Instruction not finished, + NOTATION: Name expected here, + '' required to close NOTATION declaration, + '(' required to start ATTLIST enumeration, + '(' required to start ATTLIST enumeration, + MixedContentDecl : '|' or ')*' expected, XML_ERR_MIXED_NOT_FINISHED, - XML_ERR_ELEMCONTENT_NOT_STARTED, - XML_ERR_ELEMCONTENT_NOT_FINISHED, - XML_ERR_XMLDECL_NOT_STARTED, - XML_ERR_XMLDECL_NOT_FINISHED, + ELEMENT in DTD not started, + ELEMENT in DTD not finished, + XML declaration not started, + XML declaration not finished, XML_ERR_CONDSEC_NOT_STARTED, - XML_ERR_CONDSEC_NOT_FINISHED, - XML_ERR_EXT_SUBSET_NOT_FINISHED, - XML_ERR_DOCTYPE_NOT_FINISHED, - XML_ERR_MISPLACED_CDATA_END, - XML_ERR_CDATA_NOT_FINISHED, - XML_ERR_RESERVED_XML_NAME, - XML_ERR_SPACE_REQUIRED, + XML conditional section not closed, + Content error in the external subset, + DOCTYPE not finished, + Sequence ']]' not allowed in content, + CDATA not finished, + Reserved XML Name, + Space required, XML_ERR_SEPARATOR_REQUIRED, - XML_ERR_NMTOKEN_REQUIRED, + NmToken expected in ATTLIST enumeration, XML_ERR_NAME_REQUIRED, - XML_ERR_PCDATA_REQUIRED, - XML_ERR_URI_REQUIRED, - XML_ERR_PUBID_REQUIRED, - XML_ERR_LT_REQUIRED, - XML_ERR_GT_REQUIRED, - XML_ERR_LTSLASH_REQUIRED, - XML_ERR_EQUAL_REQUIRED, - XML_ERR_TAG_NAME_MISMATCH, - XML_ERR_TAG_NOT_FINISHED, - XML_ERR_STANDALONE_VALUE, - XML_ERR_ENCODING_NAME, - XML_ERR_HYPHEN_IN_COMMENT, + MixedContentDecl : '#PCDATA' expected, + SYSTEM or PUBLIC, the URI is missing, + PUBLIC, the Public Identifier is missing, +required, +
[PHP-CVS] cvs: php-src /ext/xml compat.c xml.c
rrichards Wed Apr 7 12:24:17 2004 EDT Modified files: /php-src/ext/xmlcompat.c xml.c Log: Fix bug #27821 xml_parse segfaults when xml_set_object called from class method fix memleaks in compat.c http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.31r2=1.32ty=u Index: php-src/ext/xml/compat.c diff -u php-src/ext/xml/compat.c:1.31 php-src/ext/xml/compat.c:1.32 --- php-src/ext/xml/compat.c:1.31 Tue Feb 24 07:03:32 2004 +++ php-src/ext/xml/compat.cWed Apr 7 12:24:17 2004 @@ -232,6 +232,7 @@ _build_comment(comment, xmlStrlen(comment), d_comment, d_comment_len); parser-h_default(parser-user, d_comment, d_comment_len); + xmlFree(d_comment); } } @@ -257,6 +258,7 @@ _build_entity(name, xmlStrlen(name), entity, len); parser-h_default(parser-user, (const xmlChar *) entity, len); + xmlFree(entity); } return NULL; http://cvs.php.net/diff.php/php-src/ext/xml/xml.c?r1=1.150r2=1.151ty=u Index: php-src/ext/xml/xml.c diff -u php-src/ext/xml/xml.c:1.150 php-src/ext/xml/xml.c:1.151 --- php-src/ext/xml/xml.c:1.150 Mon Feb 23 11:19:39 2004 +++ php-src/ext/xml/xml.c Wed Apr 7 12:24:17 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: xml.c,v 1.150 2004/02/23 16:19:39 chregu Exp $ */ +/* $Id: xml.c,v 1.151 2004/04/07 16:24:17 rrichards Exp $ */ #define IS_EXT_MODULE @@ -380,6 +380,9 @@ if (parser-baseURI) { efree(parser-baseURI); } + if (parser-object) { + zval_ptr_dtor(parser-object); + } efree(parser); } @@ -1141,14 +1144,17 @@ if (parser-object) { zval_ptr_dtor(parser-object); } - - parser-object = *mythis; /* please leave this commented - or ask [EMAIL PROTECTED] before doing it (again) */ /* #ifdef ZEND_ENGINE_2 zval_add_ref(parser-object); #endif */ + ALLOC_ZVAL(parser-object); + *parser-object = **mythis; + zval_copy_ctor(parser-object); + INIT_PZVAL(parser-object); + RETVAL_TRUE; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/xml compat.c xml.c
chregu Mon Feb 23 03:21:11 2004 EDT Modified files: /php-src/ext/xmlcompat.c xml.c Log: - make it compile with libxml2 2.5 again - disable xml_parser_create_ns with libxml2 2.5 for the time being - the #if s can be removed, once we insist on libxml2 2.6 http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.26r2=1.27ty=u Index: php-src/ext/xml/compat.c diff -u php-src/ext/xml/compat.c:1.26 php-src/ext/xml/compat.c:1.27 --- php-src/ext/xml/compat.c:1.26 Sun Feb 22 12:51:01 2004 +++ php-src/ext/xml/compat.cMon Feb 23 03:21:07 2004 @@ -63,6 +63,7 @@ xmlFree(qualified_name); } +#if LIBXML_VERSION = 20600 static void _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes) { @@ -77,6 +78,7 @@ xmlFree(qualified_name); } +#endif static void _namespace_handler(XML_Parser parser, xmlNsPtr nsptr) @@ -104,6 +106,7 @@ xmlFree(qualified_name); } +#if LIBXML_VERSION = 20600 static void _end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, const xmlChar *URI) { @@ -120,6 +123,7 @@ xmlFree(qualified_name); } +#endif static void _cdata_handler(void *user, const xmlChar *cdata, int cdata_len) @@ -268,11 +272,14 @@ NULL, /* getParameterEntity */ _cdata_handler, /* cdataBlock */ NULL, /* externalSubset */ - 1, + 1 +#if LIBXML_VERSION = 20600 + , NULL, _start_element_handler_ns, _end_element_handler_ns, NULL +#endif }; @@ -314,7 +321,9 @@ parser-parser-replaceEntities = 1; if (sep != NULL) { parser-use_namespace = 1; +#if LIBXML_VERSION = 20600 parser-parser-sax2 = 1; +#endif parser-_ns_seperator = xmlStrdup(sep); } return parser; @@ -396,6 +405,7 @@ PHPAPI int XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final) { +#if LIBXML_VERSION = 20600 int error; error = xmlParseChunk(parser-parser, data, data_len, is_final); if (!error) { @@ -405,6 +415,9 @@ } else { return 1; } +#else + return !xmlParseChunk(parser-parser, data, data_len, is_final); +#endif } PHPAPI int http://cvs.php.net/diff.php/php-src/ext/xml/xml.c?r1=1.147r2=1.148ty=u Index: php-src/ext/xml/xml.c diff -u php-src/ext/xml/xml.c:1.147 php-src/ext/xml/xml.c:1.148 --- php-src/ext/xml/xml.c:1.147 Sat Jan 17 12:44:26 2004 +++ php-src/ext/xml/xml.c Mon Feb 23 03:21:07 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: xml.c,v 1.147 2004/01/17 17:44:26 andrey Exp $ */ +/* $Id: xml.c,v 1.148 2004/02/23 08:21:07 chregu Exp $ */ #define IS_EXT_MODULE @@ -1109,7 +1109,11 @@ Create an XML parser */ PHP_FUNCTION(xml_parser_create_ns) { +#if defined(HAVE_LIBXML) defined(HAVE_XML) !defined(HAVE_LIBEXPAT) LIBXML_VERSION 20600 + php_error_docref(NULL TSRMLS_CC, E_ERROR, is broken with libxml2 %d. Please upgrade to libxml2 2.6, LIBXML_DOTTED_VERSION); +#else php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); +#endif } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php