[BUGFIX] Trim input into xml2array 17/50717/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 20 Nov 2016 08:42:59 +0000 (09:42 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 20 Nov 2016 12:53:25 +0000 (13:53 +0100)
Preciding whitespace in the xml input string causes xml2array()
to fail with an error message. This whitespace is often
introduced by formatting code via IDE, so blaming the developer
only helps so far. Inserting a trim() before the input is processed
mitigates the problem.

Resolves: #78752
Releases: master, 7.6
Change-Id: I3b9d3c81b64d502e7cefef80e72bef3a1bd9b3da
Reviewed-on: https://review.typo3.org/50717
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 69e0cf7..dbda2ab 100644 (file)
@@ -2216,7 +2216,7 @@ class GeneralUtility
             // @todo: Is this cache really required? It basically substitutes a little cpu work with a db query?
             $array = PageRepository::getHash($identifier, 0);
             if (!is_array($array)) {
             // @todo: Is this cache really required? It basically substitutes a little cpu work with a db query?
             $array = PageRepository::getHash($identifier, 0);
             if (!is_array($array)) {
-                $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
+                $array = self::xml2arrayProcess(trim($string), $NSprefix, $reportDocTag);
                 PageRepository::storeHash($identifier, $array, 'ident_xml2array');
             }
             // Store content in first level cache
                 PageRepository::storeHash($identifier, $array, 'ident_xml2array');
             }
             // Store content in first level cache