summaryrefslogtreecommitdiff
path: root/ext/dom/node.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmb@php.net>2015-07-07 14:55:00 +0200
committerChristoph M. Becker <cmb@php.net>2015-09-05 01:17:50 +0200
commitb2954c64ab67bca980070c63f43cb7afb7ed6d16 (patch)
tree0ac81a08bcc5683a33d7a7232a386fc412fa4b07 /ext/dom/node.c
parentb59ea797f53f560ae79c55c1ca4956b5e77203d2 (diff)
downloadphp-git-b2954c64ab67bca980070c63f43cb7afb7ed6d16.tar.gz
Fix #70001: Assigning to DOMNode::textContent does additional entity encoding
Assigning to DOMNode::textContent encodes entities, what does not match the behavior of DOMText::__construct() and DOMDocument::createTextNode. This patch changes the behavior of DOMNode::textContent in this regard.
Diffstat (limited to 'ext/dom/node.c')
-rw-r--r--ext/dom/node.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 887d6d8009..5b955c06f3 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -930,7 +930,6 @@ int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC)
{
xmlNode *nodep = dom_object_get_node(obj);
zval value_copy;
- xmlChar *enc_str;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
@@ -938,9 +937,9 @@ int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC)
}
convert_to_string_copy(newval, value_copy);
- enc_str = xmlEncodeEntitiesReentrant(nodep->doc, Z_STRVAL_P(newval));
- xmlNodeSetContent(nodep, enc_str);
- xmlFree(enc_str);
+ /* we have to use xmlNodeAddContent() to get the same behavior as with xmlNewText() */
+ xmlNodeSetContent(nodep, (xmlChar *) "");
+ xmlNodeAddContent(nodep, Z_STRVAL_P(newval));
if (newval == &value_copy) {
zval_dtor(newval);
}