Bug #70001 [Csd]: Assigning to DOMNode::textContent does additional entity encoding

From: Date: Fri, 04 Sep 2015 23:38:44 +0000
Subject: Bug #70001 [Csd]: Assigning to DOMNode::textContent does additional entity encoding
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195775@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70001&edit=1 ID: 70001 Updated by: cmb@php.net Reported by: 2detaz at protonmail dot ch Summary: Assigning to DOMNode::textContent does additional entity encoding Status: Closed Type: Bug Package: DOM XML related Operating System: Linux Debian 7.5 Wheezy PHP Version: 5.6.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2015-09-04 23:36:02] cmb@php.net Automatic comment on behalf of cmb Revision: http://git.php.net/?p=php-src.git;a=commit;h=b2954c64ab67bca980070c63f43cb7afb7ed6d16 Log: Fix #70001: Assigning to DOMNode::textContent does additional entity encoding ------------------------------------------------------------------------ [2015-07-07 13:18:15] cmb@php.net The missing info that DOMNode::textContent is writable as of PHP 5.6.1 has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. With regard to the additional entity encoding, I've submitted PR #1395. ------------------------------------------------------------------------ [2015-07-06 21:04:01] requinix@php.net https://github.com/php/php-src/commit/f54451c#diff-fa17cddc8718bbe954a564fc2f88164dL943 Text interface: http://www.w3.org/TR/dom/#interface-text textContent attribute: http://www.w3.org/TR/dom/#dom-node-textcontent Using the constructor and setting textContent directly (which is permitted) should definitely behave the same way, and nothing I've seen suggests either involves HTML encoding. ------------------------------------------------------------------------ [2015-07-06 15:09:48] cmb@php.net Confirmed: <http://3v4l.org/lbeVg>. From the changelog of PHP 5.6.1[1]: | Made DOMNode::textContent writeable. So this has to be documented. I'm not sure whether the entity escaping is intended. [1] <http://de2.php.net/ChangeLog-5.php#5.6.1> ------------------------------------------------------------------------ [2015-07-06 12:35:49] 2detaz at protonmail dot ch Description: ------------ Version : PHP 5.6.10-1~dotdeb+7.3 (cli) (built: Jun 15 2015 07:22:09) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies DomNode::textContent is readonly on the php doc http://php.net/manual/en/class.domnode.php#domnode.props.textcontent. As excepted on php5.4.42, the script returns the good result. But on php5.6, the textContent is not readonly and I don't know why PHP does some HTML entity encoding (that's weird) instead of emitting an error or a warning. Test script: --------------- $element = new DOMText(" Summary for Test DOMText & with a nbsp char right here&nbsp;."); var_dump($element->textContent); $element->textContent = ltrim(" Summary for Test DOMText & with a nbsp char right here&nbsp;."); var_dump($element->textContent); Expected result: ---------------- string(92) " Summary for Test DOMText & with a nbsp char right here&nbsp;." string(92) " Summary for Test DOMText & with a nbsp char right here&nbsp;." Actual result: -------------- string(92) " Summary for Test DOMText & with a nbsp char right here&nbsp;." string(69) "Summary for Test DOMText &amp; with a nbsp char right here&amp;nbsp;.". ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70001&edit=1

« previous php.bugs (#195775) next »