[BUGFIX] InvalidXmlFileException for invalid locallang.xml 61/51761/9
authorSascha Egerer <sascha@sascha-egerer.de>
Sun, 19 Feb 2017 20:34:53 +0000 (21:34 +0100)
committerHelmut Hummel <typo3@helhum.io>
Sat, 25 Feb 2017 14:51:36 +0000 (15:51 +0100)
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>
typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php

index 248a8c9..1d261a8 100644 (file)
@@ -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') {