Bug #70001 [Opn->Ver]: overwrite DOMElement textContent properties with trimming
Edit report at https://bugs.php.net/bug.php?id=70001&edit=1
ID: 70001
Updated by: requinix@php.net
Reported by: 2detaz at protonmail dot ch
Summary: overwrite DOMElement textContent properties with
trimming
-Status: Open
+Status: Verified
Type: Bug
Package: DOM XML related
Operating System: Linux Debian 7.5 Wheezy
PHP Version: 5.6.10
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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 .");
var_dump($element->textContent);
$element->textContent = ltrim(" Summary for Test DOMText & with a nbsp char right
here .");
var_dump($element->textContent);
Expected result:
----------------
string(92) " Summary for Test DOMText & with a nbsp char right here ."
string(92) " Summary for Test DOMText & with a nbsp char right here ."
Actual result:
--------------
string(92) " Summary for Test DOMText & with a nbsp char right here ."
string(69) "Summary for Test DOMText & with a nbsp char right
here&nbsp;.".
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70001&edit=1
Thread (6 messages)