#85635Broken <script> tag after XML import
Description
If bodytext contains <script src="/some/script.js"></script>, it would be replaced with <script src="/script.js"> after importing the XML file with the localization manager. This is not valid HTML and brakes a page. The translated file has valid XML containing valid HTML with a closing tag, so the replacement happens during the import process.</p></script>
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 11
-
Coders.Care Extension Team commented and changed status
NewNeeds Feedback 07/24/18, 20:52 -
Coders.Care Extension Team commented 07/24/18, 21:13
It seems to be a core bug, since the CatXmlImportManager uses
GeneralUtility::xml2tree
to transform the XML code.
That again uses xmlRecompileFromStructValArray to implode array structures back into XML.
If there is no value, this method automatically closes any opening tag into a self closing tag instead of using a closing tag for tags that are not allowed to be self closing.
If the type is detected as “cdata” the whole value is just added as is, which is why CDATA works./** * This implodes an array of XML parts (made with xml_parse_into_struct()) into XML again. * * @param array $vals An array of XML parts, see xml2tree * @return string Re-compiled XML data. */ public static function xmlRecompileFromStructValArray(array $vals) { $XMLcontent = ''; foreach ($vals as $val) { $type = $val['type']; // Open tag: if ($type === 'open' || $type === 'complete') { $XMLcontent .= '<' . $val['tag']; if (isset($val['attributes'])) { foreach ($val['attributes'] as $k => $v) { $XMLcontent .= ' ' . $k . '="' . htmlspecialchars($v) . '"'; } } if ($type === 'complete') { if (isset($val['value'])) { $XMLcontent .= '>' . htmlspecialchars($val['value']) . '</' . $val['tag'] . '>'; } else { $XMLcontent .= '/>'; } } else { $XMLcontent .= '>'; } if ($type === 'open' && isset($val['value'])) { $XMLcontent .= htmlspecialchars($val['value']); } } // Finish tag: if ($type === 'close') { $XMLcontent .= '</' . $val['tag'] . '>'; } // Cdata if ($type === 'cdata') { $XMLcontent .= htmlspecialchars($val['value']); } } return $XMLcontent; }To get a better understanding of the types “open”, “complete” and “close”, see
http://php.net/manual/de/function.xml-parse-into-struct.php -
Coders.Care Extension Team changed project id description category removed the assignee target version PHP Version 7.0 07/24/18, 21:18
-
Coders.Care Extension Team commented 07/24/18, 21:19
Since the method is quite old, I guess this happens with CMS 6 and 7 as well.
-
Coders.Care Extension Team commented 07/24/18, 21:25
According to HTML5 specs, the following tags are allowed to be “void” and therefor self closing.
area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
-
Dmitry no-lastname-given commented 07/25/18, 16:42
Coders.Care Extension Team wrote:
> Could you please check your file again to find out if there is any -
Coders.Care Extension Team commented and changed assigned to Jo Hasenau 07/26/18, 11:20
As a workaround you can check the checkbox “Do not check XML” – this automatically wraps content with CDATA to make sure it does not break the XML parser. Still this is just a workaround for the L10nmgr but the bug in xmlRecompileFromStructValArray should be fixed anyway.
-
Dmitry no-lastname-given commented 08/02/18, 20:16
Coders.Care Extension Team wrote:
> As a workaround you can check the checkbox “Do not check XML” – this automatically wraps content with CDATA to make sure it does not break the XML parser. Still this is just a workaround for the L10nmgr but the bug in xmlRecompileFromStructValArray should be fixed anyway.It’s already checked. If I don’t check it – export fails.
-
Benni Mack changed target version 04/17/19, 23:42
-
Susanne Moog commented 03/24/20, 16:59
Can somebody summarize what the core bug here is and what needs fixing exactly?
-
Christian Kuhn commented and changed status
Needs FeedbackClosed 02/19/22, 12:49Hey. It is quite hard to understand what the real issue is in this case. A request from Susi to clearify has not been answered. At the moment I see no other solution than to close this issue for now. If the problem persists, we should probably start with a fresh issue describing the problem again.
Could you please check your file again to find out if there is any