mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Merge branch 'PHP-5.6'
* PHP-5.6: Fix #70001: Assigning to DOMNode::textContent does additional entity encoding Resolved conflicts: ext/dom/node.c
This commit is contained in:
commit
c9a8733ce2
@ -847,7 +847,6 @@ int dom_node_text_content_write(dom_object *obj, zval *newval)
|
|||||||
{
|
{
|
||||||
xmlNode *nodep = dom_object_get_node(obj);
|
xmlNode *nodep = dom_object_get_node(obj);
|
||||||
zend_string *str;
|
zend_string *str;
|
||||||
xmlChar *enc_str;
|
|
||||||
|
|
||||||
if (nodep == NULL) {
|
if (nodep == NULL) {
|
||||||
php_dom_throw_error(INVALID_STATE_ERR, 0);
|
php_dom_throw_error(INVALID_STATE_ERR, 0);
|
||||||
@ -855,9 +854,9 @@ int dom_node_text_content_write(dom_object *obj, zval *newval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
str = zval_get_string(newval);
|
str = zval_get_string(newval);
|
||||||
enc_str = xmlEncodeEntitiesReentrant(nodep->doc, (xmlChar *) ZSTR_VAL(str));
|
/* we have to use xmlNodeAddContent() to get the same behavior as with xmlNewText() */
|
||||||
xmlNodeSetContent(nodep, enc_str);
|
xmlNodeSetContent(nodep, (xmlChar *) "");
|
||||||
xmlFree(enc_str);
|
xmlNodeAddContent(nodep, ZSTR_VAL(str));
|
||||||
zend_string_release(str);
|
zend_string_release(str);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
17
ext/dom/tests/bug70001.phpt
Normal file
17
ext/dom/tests/bug70001.phpt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
--TEST--
|
||||||
|
Bug #70001 (Assigning to DOMNode::textContent does additional entity encoding)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once('skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$element = new DOMText('<p>foo & bar</p>');
|
||||||
|
var_dump($element->textContent);
|
||||||
|
$element = (new DOMDocument())->createTextNode('<p>foo & bar</p>');
|
||||||
|
var_dump($element->textContent);
|
||||||
|
$element->textContent = ('<p>foo & bar</p>');
|
||||||
|
var_dump($element->textContent);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(16) "<p>foo & bar</p>"
|
||||||
|
string(16) "<p>foo & bar</p>"
|
||||||
|
string(16) "<p>foo & bar</p>"
|
Loading…
Reference in New Issue
Block a user