[BUGFIX] TS Parser: Fix regression when having tabs in TS names 69/27069/3
authorBenjamin Mack <benni@typo3.org>
Mon, 27 Jan 2014 12:51:13 +0000 (13:51 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 28 Jan 2014 13:07:45 +0000 (14:07 +0100)
With the optimization of the TS parser (see #54856), it is not
possible to write TypoScript like this anymore:

config {
    baseUrl            = www.mywebsite.com
    tx_realurl_enable    = 1
}
The problem is that the TS parser is not allowing tabs
after the TS object name (baseUrl). The fix strips away
tabs after the TS object name.

Resolves: #55357
Releases: 6.2
Change-Id: I880267c2b512e50d6b9e47f469157ea5fd814180
Reviewed-on: https://review.typo3.org/27069
Reviewed-by: Michiel Roos
Tested-by: Michiel Roos
Reviewed-by: Wouter Wolters
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php

index 6fea406..c375443 100644 (file)
@@ -355,7 +355,8 @@ class TypoScriptParser {
                                        } elseif ($line{0} !== '}' && $line{0} !== '#' && $line{0} !== '/') {
                                                // If not brace-end or comment
                                                // Find object name string until we meet an operator
-                                               $varL = strcspn($line, ' {=<>:(');
+                                               $varL = strcspn($line, TAB . ' {=<>:(');
+                                               // also remove tabs after the object string name
                                                $objStrName = substr($line, 0, $varL);
                                                if ($this->syntaxHighLight) {
                                                        $this->regHighLight('objstr', $lineP, strlen(substr($line, $varL)));
index bd45ec2..bb66082 100644 (file)
@@ -338,6 +338,12 @@ class TypoScriptParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                        )
                                ),
                        ),
+                       'simple assignment operator with tab character before "="' => array(
+                               'test    = someValue',
+                               array(
+                                       'test' => 'someValue',
+                               ),
+                       ),
                        'simple assignment operator character as value "="' => array(
                                'test ==TEST=',
                                array(