helly Mon Oct 24 04:29:37 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/simplexml/tests 023.phpt
Modified files:
/php-src/ext/simplexml simplexml.c
Log:
- Fix issue with entities in attributes
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.151.2.3&r2=1.151.2.4&ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.3
php-src/ext/simplexml/simplexml.c:1.151.2.4
--- php-src/ext/simplexml/simplexml.c:1.151.2.3 Mon Oct 3 12:05:08 2005
+++ php-src/ext/simplexml/simplexml.c Mon Oct 24 04:29:32 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.151.2.3 2005/10/03 16:05:08 helly Exp $ */
+/* $Id: simplexml.c,v 1.151.2.4 2005/10/24 08:29:32 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -689,10 +689,15 @@
GET_NODE(sxe, node);
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
-
- if (node) {
- node = node->children;
-
+ if (node && sxe->iter.type != SXE_ITER_ATTRLIST) {
+ if (node->type == XML_ATTRIBUTE_NODE) {
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRING(value, xmlNodeListGetString(node->doc,
node->children, 1), 1);
+ zend_hash_next_index_insert(rv, &value, sizeof(zval *),
NULL);
+ node = NULL;
+ } else {
+ node = node->children;
+ }
while (node) {
if (node->children != NULL || node->prev != NULL ||
node->next != NULL) {
SKIP_TEXT(node);
@@ -1738,7 +1743,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.3 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.4 $");
php_info_print_table_row(2, "Schema support",
#ifdef LIBXML_SCHEMAS_ENABLED
"enabled");
http://cvs.php.net/co.php/php-src/ext/simplexml/tests/023.phpt?r=1.1&p=1
Index: php-src/ext/simplexml/tests/023.phpt
+++ php-src/ext/simplexml/tests/023.phpt
--TEST--
SimpleXML: Attributes with entities
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
$xml =<<<EOF
<?xml version='1.0'?>
<!DOCTYPE talks SYSTEM "nbsp.dtd" [
<!ELEMENT root EMPTY>
<!ATTLIST root attr1 CDATA #IMPLIED>
<!ENTITY nbsp "&#x00A0;">
]>
<root attr='foo bar baz'></root>
EOF;
$sxe = simplexml_load_string($xml);
var_dump($sxe);
var_dump($sxe['attr']);
?>
===DONE===
--EXPECTF--
object(SimpleXMLElement)#1 (1) {
["attr"]=>
string(%d) "foo%sbar%sbaz"
}
object(SimpleXMLElement)#2 (1) {
[0]=>
string(%d) "foo%sbar%sbaz"
}
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php