[TASK] Use file_get_contents instead of getUrl()
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / TypoScript / Parser / TypoScriptParser.php
index ab80353..1596b84 100644 (file)
@@ -14,13 +14,13 @@ namespace TYPO3\CMS\Core\TypoScript\Parser;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
-use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
-use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
 
 /**
  * The TypoScript parser
@@ -28,13 +28,6 @@ use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatche
 class TypoScriptParser
 {
     /**
-     * If set, then key names cannot contain characters other than [:alnum:]_\.-
-     *
-     * @var bool
-     */
-    public $strict = true;
-
-    /**
      * TypoScript hierarchy being build during parsing.
      *
      * @var array
@@ -242,7 +235,7 @@ class TypoScriptParser
         $pre = '[GLOBAL]';
         while ($pre) {
             if ($this->breakPointLN && $pre === '[_BREAK]') {
-                $this->error('Breakpoint at ' . ($this->lineNumberOffset + $this->rawP - 2) . ': Line content was "' . $this->raw[($this->rawP - 2)] . '"', 1);
+                $this->error('Breakpoint at ' . ($this->lineNumberOffset + $this->rawP - 2) . ': Line content was "' . $this->raw[$this->rawP - 2] . '"', 1);
                 break;
             }
             $preUppercase = strtoupper($pre);
@@ -383,7 +376,7 @@ class TypoScriptParser
                         }
                         if ($objStrName !== '') {
                             $r = array();
-                            if ($this->strict && preg_match('/[^[:alnum:]_\\\\\\.:-]/i', $objStrName, $r)) {
+                            if (preg_match('/[^[:alnum:]_\\\\\\.:-]/i', $objStrName, $r)) {
                                 $this->error('Line ' . ($this->lineNumberOffset + $this->rawP - 1) . ': Object Name String, "' . htmlspecialchars($objStrName) . '" contains invalid character "' . $r[0] . '". Must be alphanumeric or one of: "_:-\\."');
                             } else {
                                 $line = ltrim(substr($line, $varL));
@@ -437,7 +430,7 @@ class TypoScriptParser
                                                     return $exitSig;
                                                 }
                                             } else {
-                                                if (!isset($setup[($objStrName . '.')])) {
+                                                if (!isset($setup[$objStrName . '.'])) {
                                                     $setup[$objStrName . '.'] = array();
                                                 }
                                                 $exitSig = $this->parseSub($setup[$objStrName . '.']);
@@ -685,7 +678,7 @@ class TypoScriptParser
                 }
             } else {
                 $lnRegisDone = 0;
-                if ($wipeOut && $this->strict) {
+                if ($wipeOut) {
                     unset($setup[$key]);
                     unset($setup[$subKey]);
                     if ($this->regLinenumbers) {
@@ -771,7 +764,7 @@ class TypoScriptParser
      * If "TT" is a global object (as it is in the frontend when backend users are logged in) the message will be registered here as well.
      *
      * @param string $err The error message string
-     * @param int $num The error severity (in the scale of $GLOBALS['TT']->setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
+     * @param int $num The error severity (in the scale of TimeTracker::setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
      * @return void
      */
     public function error($err, $num = 2)
@@ -877,9 +870,8 @@ class TypoScriptParser
                 // load default TypoScript for content rendering templates like
                 // css_styled_content if those have been included through f.e.
                 // <INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/static/setup.txt">
-                $filePointer = strtolower($filename);
-                if (StringUtility::beginsWith($filePointer, 'ext:')) {
-                    $filePointerPathParts = explode('/', substr($filePointer, 4));
+                if (StringUtility::beginsWith(strtolower($filename), 'ext:')) {
+                    $filePointerPathParts = explode('/', substr($filename, 4));
 
                     // remove file part, determine whether to load setup or constants
                     list($includeType, ) = explode('.', array_pop($filePointerPathParts));
@@ -944,7 +936,7 @@ class TypoScriptParser
             } else {
                 $includedFiles[] = $absfilename;
                 // check for includes in included text
-                $included_text = self::checkIncludeLines(GeneralUtility::getUrl($absfilename), $cycle_counter + 1, $returnFiles, $absfilename);
+                $included_text = self::checkIncludeLines(file_get_contents($absfilename), $cycle_counter + 1, $returnFiles, $absfilename);
                 // If the method also has to return all included files, merge currently included
                 // files with files included by recursively calling itself
                 if ($returnFiles && is_array($included_text)) {
@@ -1313,10 +1305,9 @@ class TypoScriptParser
      */
     protected function getTimeTracker()
     {
-        return isset($GLOBALS['TT']) ? $GLOBALS['TT'] : null;
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
-
     /**
      * Modifies a HTML Hex color by adding/subtracting $R,$G and $B integers
      *