#26528 [Opn]: xml_parse_into_struct does not unescape attribute values

From: Date: Thu, 04 Dec 2003 22:20:45 +0000
Subject: #26528 [Opn]: xml_parse_into_struct does not unescape attribute values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-51710@lists.php.net to get a copy of this message
ID: 26528 User updated by: archie at dellroad dot org Reported By: archie at dellroad dot org Status: Open Bug Type: XML related Operating System: Linux redhat 9 PHP Version: 5.0.0b2 (beta2) New Comment: Tried reconfiguring using --with-libexpat-dir but now it doesn't build: gcc -Iext/xml/ -I/home/archie/php-5.0.0b2/ext/xml/ -DPHP_ATOM_INC -I/home/archie/php-5.0.0b2/include -I/home/archie/php-5.0.0b2/main -I/home/archie/php-5.0.0b2 -I/home/archie/php-5.0.0b2/Zend -I/usr/local/include/libxml2 -I/usr/include/mysql -I/usr/local/include -I/include -I/home/archie/php-5.0.0b2/TSRM -g -O2 -Wall -Wcast-align -Wchar-subscripts -Wformat -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -c /home/archie/php-5.0.0b2/ext/xml/compat.c -o ext/xml/compat.o && echo > ext/xml/compat.lo /home/archie/php-5.0.0b2/ext/xml/compat.c:24: parse error before "xmlNsPtr" /home/archie/php-5.0.0b2/ext/xml/compat.c:24: warning: no semicolon at end of struct or union /home/archie/php-5.0.0b2/ext/xml/compat.c:28: parse error before '}' token /home/archie/php-5.0.0b2/ext/xml/compat.c:28: warning: type defaults to int' in declaration of php_xml_ns' /home/archie/php-5.0.0b2/ext/xml/compat.c:28: warning: data definition has no type or storage class make: *** [ext/xml/compat.lo] Error 1 Previous Comments: ------------------------------------------------------------------------ [2003-12-04 17:09:43] archie at dellroad dot org I noticed that the version of PHP that came with redhat 9 does not have this bug. It is liked to expat: $ldd /usr/bin/php ... libexpat.so.0 => /usr/lib/libexpat.so.0 (0x40028000) whereas my php-5.0.0b2 does not link to expat. So I guess the routines in libxml2 are not compatible with the ones in libexpat.. ? ------------------------------------------------------------------------ [2003-12-04 17:00:56] archie at dellroad dot org Description: ------------ When the function xml_parse_into_struct() is used, XML attribute values that contain escaped characters in them are not properly un-escaped. E.g. suppose the tag is: <governor name="Jesse &quot;The Body&quot; Ventura"/> Then the attribute is returned still escaped, as Jesse &quot;The Body&quot; Ventura rather than Jesse "The Body" Ventura like it should be. This function is supposed to parse the XML, and &-encodings are part of XML, so it should properly decode them! Here's ldd output for my test version of PHP: $ ldd ~/php-5.0.0b2/sapi/cli/php libcrypt.so.1 => /lib/libcrypt.so.1 (0x40017000) librt.so.1 => /lib/i686/librt.so.1 (0x40064000) libm.so.6 => /lib/i686/libm.so.6 (0x4007f000) libmysqlclient.so.10 => /usr/lib/mysql/libmysqlclient.so.10 (0x400cc000) libresolv.so.2 => /lib/libresolv.so.2 (0x40103000) libdl.so.2 => /lib/libdl.so.2 (0x40116000) libnsl.so.1 => /lib/libnsl.so.1 (0x4011a000) libz.so.1 => /usr/lib/libz.so.1 (0x40140000) libxml2.so.2 => /usr/local/lib/libxml2.so.2 (0x4014e000) libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40237000) libc.so.6 => /lib/i686/libc.so.6 (0x40287000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) Reproduce code: --------------- <?php $sample = "<?xml version=\"1.0\"?><test attr=\"angle&lt;bracket\"/>"; $parser = xml_parser_create(); $res = xml_parse_into_struct($parser,$sample,$vals,$index); xml_parser_free($parser); var_dump($vals); ?> Expected result: ---------------- array(1) { [0]=> array(4) { ["tag"]=> string(4) "TEST" ["type"]=> string(8) "complete" ["level"]=> int(1) ["attributes"]=> array(1) { ["ATTR"]=> string(16) "angle<bracket" } } } Actual result: -------------- array(1) { [0]=> array(4) { ["tag"]=> string(4) "TEST" ["type"]=> string(8) "complete" ["level"]=> int(1) ["attributes"]=> array(1) { ["ATTR"]=> string(16) "angle&lt;bracket" } } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26528&edit=1

« previous php.bugs (#51710) next »