From b25c54153536d132d08257f056de2ecad19acb8d Mon Sep 17 00:00:00 2001 From: Sascha Egerer <sascha@sascha-egerer.de> Date: Sun, 19 Feb 2017 21:34:53 +0100 Subject: [PATCH] [BUGFIX] InvalidXmlFileException for invalid locallang.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Throw a meaningful InvalidXmlFileException when an invalid locallang.xml file is detected. Resolves: #79908 Releases: master, 7.6 Change-Id: Idc5586166d2475edeaeef407128525ea57fb9a09 Reviewed-on: https://review.typo3.org/51761 Reviewed-by: Stephan Großberndt <stephan@grossberndt.de> Tested-by: Stephan Großberndt <stephan@grossberndt.de> Reviewed-by: Thomas Hohn <thomas@hohn.dk> Reviewed-by: Anders Kostending <aha@systime.dk> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Faton Haliti <fha@systime.dk> Tested-by: Faton Haliti <fha@systime.dk> Reviewed-by: Helmut Hummel <typo3@helhum.io> Tested-by: Helmut Hummel <typo3@helhum.io> --- .../core/Classes/Localization/Parser/LocallangXmlParser.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php b/typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php index 248a8c914fe6..1d261a895f32 100644 --- a/typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php +++ b/typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Localization\Parser; use TYPO3\CMS\Core\Localization\Exception\InvalidXmlFileException; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\PathUtility; /** * Parser for XML locallang file. @@ -65,10 +66,15 @@ class LocallangXmlParser extends AbstractXmlParser * @param \SimpleXMLElement $root XML root element * @param string $element Target or Source * @return array + * @throws InvalidXmlFileException */ protected function doParsingFromRootForElement(\SimpleXMLElement $root, $element) { $bodyOfFileTag = $root->data->languageKey; + if ($bodyOfFileTag === null) { + throw new InvalidXmlFileException('Invalid locallang.xml language file "' . PathUtility::stripPathSitePrefix($this->sourcePath) . '"', 1487944884); + } + // Check if the source llxml file contains localized records $localizedBodyOfFileTag = $root->data->xpath('languageKey[@index=\'' . $this->languageKey . '\']'); if ($element === 'source' || $this->languageKey === 'default') { -- GitLab