Bug #70001 [Opn]: overwrite DOMElement textContent properties with trimming

From: Date: Mon, 06 Jul 2015 15:09:49 +0000
Subject: Bug #70001 [Opn]: overwrite DOMElement textContent properties with trimming
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194156@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:            overwrite DOMElement textContent properties with
                     trimming
 Status:             Open
 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:

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>


Previous Comments:
------------------------------------------------------------------------
[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


Thread (6 messages)

« previous php.bugs (#194156) next »