Bug #19338

XML Problems with PHP5 and libxml 2.7.1

Added by Jeff Segars about 12 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Must have
Category:
-
Target version:
-
Start date:
2008-09-16
Due date:
% Done:

0%

TYPO3 Version:
4.2
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When using PHP5 with libxml 2.7.1, HTML entities are stripped from any XML content (FCEs, Flexforms, etc) when its saved or retrieved.

For things like RTE content, this means that "<LINK 43>Page with UID 43</LINK>" is not actually transformed into a link but instead renders in the frontend at "LINK 43Page with UID 43/LINK"

This also affects Flexible Content Elements if HTML entities were used for Typoscript assignments, such as "10 < styles.content.get". A previous working FCE and the assignment operator removed and thus renders no content at all.

For more information on the bug, see https://qa.mandriva.com/show_bug.cgi?id=43486 and http://bugs.php.net/bug.php?id=45996.

It remains to be seen how widespread this issue will become or how quickly PHP will patch it, but one helpful option for new sites is to enable the useCDATA option from t3lib_div::array2xml. This will cause TYPO3 to insert CDATA anytime there are html entities within the content. Once CDATA is present, the new content will work as expected.

I'm attaching a one line patch that enables CDATA within flexform XML. There are several other places in the core that also use XML but the flexform part seems to be the most prominent.

(issue imported from #M9359)

class.t3lib_flexformtools.php.diff View (411 Bytes) Administrator Admin, 2008-09-16 17:06

9359_v4.diff View (3.41 KB) Administrator Admin, 2009-03-18 22:36


Related issues

Duplicated by TYPO3 Core - Bug #20012: RTE in Flexform with TV stripes < > (brackets) from tags as br, p Closed 2009-02-13
Duplicated by TYPO3 Core - Bug #19433: HTML tags are removed in RTE content Closed 2008-10-08

History

#1 Updated by Kai Blaschke about 12 years ago

If you have control over the server's installed software, consider downgrading to libxml2-2.6.32. This workaround solves the problem for the moment, and not only for TYPO3, as other projects may be affected, too.

As stated in the bugs linked above, the problem lies deep inside the XML extension of PHP, and needs to be addressed carefully, including some heavy rewriting of the extension core. This usually takes a while until it's included in a new release, and since then, it's better to stick with an older libxml2 version IMHO.

#2 Updated by Steffen Kamper about 12 years ago

it reminds me to an older php-bug, where core team decided not to fix php-bugs (or workarounds) as these bugs will be hopefully solved with next php release.

#3 Updated by Tobias Liebig almost 12 years ago

Yesterday i stumpled over exactly this problem, after our hoster updated some libs on the system.
i spend a couple of hours debugging the issue and solved it exactly like jeff does in his patch.

Its true: it only solves the issue for flexforms, but not for any other cases where xml2array/xml_parse_into_struct w/o CDATA is used.

For me i would vote +1 for commiting the patch into the core, as it would fix the bug for now and does not break if PHP/libxml solves the problem afterwards. Thus its not a hack/workaround in a sense of "fixing php-bugs" as steffen mentioned.

@jeff: Go for a RFC and we will see what the other core-dev think about it.

#4 Updated by Tobias Liebig almost 12 years ago

i have prepared a minimal example demonstrating the PHP-Bug

$simple = "<root><node><strong>Teststring</strong></node></root>";
$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);
xml_parser_free($p);
echo $vals1['value'];
?>

correct output ===========
<strong>Teststring</strong>

wrong output (PHP5.2.6/libxml 2.7.1) =============================
strongTeststring/strong

#5 Updated by Steffen Kamper over 11 years ago

Hey Jeff, you made my day!!!
I found the problem on a site using xmllib 2.6.31, and your patch made it work again! 1000 Thanks!

#6 Updated by Frederik Schaller over 11 years ago

Jeff, here the same! My extension is working again! Thank you very much!

#7 Updated by Alexander Maringer over 11 years ago

The error is at the current testing debian release, too:
Debian testing
libxml2/testing uptodate 2.7.3.dfsg-1
php5/testing uptodate 5.2.6.dfsg.1-3

Please include patch in core. Thanks

#8 Updated by Steffen Kamper over 11 years ago

Committed v4 to trunk, rev 5206

Also available in: Atom PDF