Project

General

Profile

Actions

Feature #89389

closed

xmlRecompileFromStructValArray creates invalid HTML code

Added by Jo Hasenau over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Miscellaneous
Target version:
Start date:
2019-10-10
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

Description

While making use of xml2tree the function xmlRecompileFromStructValArray is involved to "implode an array of XML parts (made with xml_parse_into_struct()) into XML again."

If there are opening and closing tags in the same line, the type reported by xml_parse_into_struct is "complete".
In this case, there is a check for the content of the given tag and if that is empty, the tag will be made a self closing tag no matter what.

if ($type == 'complete') {
  if (isset($val['value'])) {
    $XMLcontent .= '>' . htmlspecialchars($val['value']) . '</' . $val['tag'] . '>';
  } else {
    $XMLcontent .= '/>';
  }
}

This will convert code like

<script type="text/javascript" src="https://some.tld/something.js"></script>
to
<script type="text/javascript" src="https://some.tld/something.js"/>
which is valid XML but invalid HTML5 and will lead to a broken frontend output.
Same for other tags like <span>

We found out about this behaviour, because translated HTML content elements were broken after exporting and reimporting them with the L10nmgr.
Still this should be a problem for any other usage of xml2tree dealing with empty tags, that should not be self closing.

This is broken in any supported version from CMS 6 up to CMS 10.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #40503: XHTML 5Closed2012-09-01

Actions
Actions

Also available in: Atom PDF