Date: Mon, 16 Feb 2009 22:01:23 +0900 (JST) From: Tsurutani Naoki <turutani@scphys.kyoto-u.ac.jp> To: FreeBSD-gnats-submit@FreeBSD.org Cc: turutani@scphys.kyoto-u.ac.jp Subject: ports/131744: textproc/php5-xml generates wrong output. Message-ID: <200902161301.n1GD1Nkd001311@h120.65.226.10.32118.vlan.kuins.net> Resent-Message-ID: <200902161310.n1GDA2AH091976@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 131744 >Category: ports >Synopsis: textproc/php5-xml generates wrong output. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Feb 16 13:10:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Tsurutani Naoki >Release: FreeBSD 7.1-STABLE i386 >Organization: >Environment: System: FreeBSD h120.65.226.10.32118.vlan.kuins.net 7.1-STABLE FreeBSD 7.1-STABLE #17: Wed Jan 7 11:14:01 JST 2009 turutani@h120.65.226.10.32118.vlan.kuins.net:/usr/local/work/usr/obj/usr/src/sys/POLYMER i386 >Description: there is a bug of losing "<" and ">" in some cases. this problem is reported on http://bugs.php.net/bug.php?id=45996 , and already fixed in php cvs trunk. >How-To-Repeat: install recent libxml2 and php5-xml (5.2.8). >Fix: here is a patch to textproc/php5-xml/files/patch-compat.c, which should be removed after new release of 5.2.9: --- patch-compat.c.orig 2004-07-20 18:03:42.000000000 +0900 +++ patch-compat.c 2009-02-16 11:20:48.000000000 +0900 @@ -1,9 +1,18 @@ ---- compat.c.orig Tue Jul 20 10:55:02 2004 -+++ compat.c Tue Jul 20 10:55:55 2004 +--- compat.c.orig 2007-12-31 16:20:14.000000000 +0900 ++++ compat.c 2009-01-13 00:45:21.000000000 +0900 +@@ -2,7 +2,7 @@ + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2008 The PHP Group | ++ | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -16,6 +16,10 @@ +----------------------------------------------------------------------+ */ - + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif @@ -11,3 +20,131 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT) #include "expat_compat.h" +@@ -40,7 +44,7 @@ + /* Use libxml functions otherwise its memory deallocation is screwed up */ + *qualified = xmlStrdup(URI); + *qualified = xmlStrncat(*qualified, parser->_ns_seperator, 1); +- *qualified = xmlStrncat(*qualified, name, strlen(name)); ++ *qualified = xmlStrncat(*qualified, name, xmlStrlen(name)); + } else { + *qualified = xmlStrdup(name); + } +@@ -104,7 +108,66 @@ + y = 0; + } + +- if (parser->h_start_element == NULL && parser->h_default == NULL) { ++ if (parser->h_start_element == NULL) { ++ if (parser->h_default) { ++ ++ if (prefix) { ++ qualified_name = xmlStrncatNew((xmlChar *)"<", prefix, xmlStrlen(prefix)); ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)":", 1); ++ qualified_name = xmlStrncat(qualified_name, name, xmlStrlen(name)); ++ } else { ++ qualified_name = xmlStrncatNew((xmlChar *)"<", name, xmlStrlen(name)); ++ } ++ ++ if (namespaces) { ++ int i, j; ++ for (i = 0,j = 0;j < nb_namespaces;j++) { ++ int ns_len; ++ char *ns_string, *ns_prefix, *ns_url; ++ ++ ns_prefix = (char *) namespaces[i++]; ++ ns_url = (char *) namespaces[i++]; ++ ++ if (ns_prefix) { ++ ns_len = spprintf(&ns_string, 0, " xmlns:%s=\"%s\"", ns_prefix, ns_url); ++ } else { ++ ns_len = spprintf(&ns_string, 0, " xmlns=\"%s\"", ns_url); ++ } ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)ns_string, ns_len); ++ ++ efree(ns_string); ++ } ++ } ++ ++ if (attributes) { ++ for (i = 0; i < nb_attributes; i += 1) { ++ int att_len; ++ char *att_string, *att_name, *att_value, *att_prefix, *att_valueend; ++ ++ att_name = (char *) attributes[y++]; ++ att_prefix = (char *)attributes[y++]; ++ y++; ++ att_value = (char *)attributes[y++]; ++ att_valueend = (char *)attributes[y++]; ++ ++ if (att_prefix) { ++ att_len = spprintf(&att_string, 0, " %s:%s=\"", att_prefix, att_name); ++ } else { ++ att_len = spprintf(&att_string, 0, " %s=\"", att_name); ++ } ++ ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)att_string, att_len); ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)att_value, att_valueend - att_value); ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)"\"", 1); ++ ++ efree(att_string); ++ } ++ ++ } ++ qualified_name = xmlStrncat(qualified_name, (xmlChar *)">", 1); ++ parser->h_default(parser->user, (const XML_Char *) qualified_name, xmlStrlen(qualified_name)); ++ xmlFree(qualified_name); ++ } + return; + } + _qualify_namespace(parser, name, URI, &qualified_name); +@@ -178,6 +241,18 @@ + XML_Parser parser = (XML_Parser) user; + + if (parser->h_end_element == NULL) { ++ if (parser->h_default) { ++ char *end_element; ++ int end_element_len; ++ ++ if (prefix) { ++ end_element_len = spprintf(&end_element, 0, "</%s:%s>", (char *) prefix, (char *)name); ++ } else { ++ end_element_len = spprintf(&end_element, 0, "</%s>", (char *)name); ++ } ++ parser->h_default(parser->user, (const XML_Char *) end_element, end_element_len); ++ efree(end_element); ++ } + return; + } + +@@ -212,7 +287,7 @@ + if (parser->h_default) { + char *full_pi; + spprintf(&full_pi, 0, "<?%s %s?>", (char *)target, (char *)data); +- parser->h_default(parser->user, (const XML_Char *) full_pi, xmlStrlen(full_pi)); ++ parser->h_default(parser->user, (const XML_Char *) full_pi, strlen(full_pi)); + efree(full_pi); + } + return; +@@ -411,6 +486,10 @@ + parser->parser->charset = XML_CHAR_ENCODING_NONE; + #endif + ++#if LIBXML_VERSION >= 20703 ++ xmlCtxtUseOptions(parser->parser, XML_PARSE_OLDSAX); ++#endif ++ + parser->parser->replaceEntities = 1; + parser->parser->wellFormed = 0; + if (sep != NULL) { +@@ -545,10 +624,10 @@ + + static const XML_Char *const error_mapping[] = { + "No error", +- "Internal error", + "No memory", + "Invalid document start", + "Empty document", ++ "Not well-formed (invalid token)", + "Invalid document end", + "Invalid hexadecimal character reference", + "Invalid decimal character reference", >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902161301.n1GD1Nkd001311>