Project

General

Profile

Actions

Bug #76447

closed

TypoScript Parse Bug

Added by Kevin Dargel almost 8 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2016-06-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The current TS-Parsing seems to ignore or take in account commented-out sections of TypoScript containing a condition (like PIDinRootline).

Put this at the end of a TS template and the following TS is not getting parsed (even TS code in the same template directly below those lines):

/*
// [PIDinRootline = 0]
[global]*/

It may be reproducible with even less code lines; I'm unsure about the real cause.
I tested this with the following TS on a SUB-PAGE or on the same page, to verify it really isn't getting parsed/handled:

page.headerData.40 = TEXT
page.headerData.40.value = <meta name="test" />

It won't take effect.
(Reproduced with Typo3 6.2.21, 24 and 25)


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Feature #16681: C style TypoScript comments with start and end in one line lead to errorsClosed2006-11-01

Actions
Related to TYPO3 Core - Bug #41327: jsInline removes closing bracketsClosedChristian Kuhn2012-09-24

Actions
Related to TYPO3 Core - Feature #97816: New TypoScript parserClosed2022-06-27

Actions
Actions #1

Updated by Markus Klein almost 8 years ago

Maybe Elmar can take a look at this, he invested some time in this area recently.

Actions #2

Updated by Kevin Dargel almost 8 years ago

  • % Done changed from 0 to 90

I found the corresponding code in the Typo3 Source.

Location: TYPO3.CMS/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php

Typo3 6.2.25 at line 483
Typo3 CMS (GitHub, Commit d1ecab6) at line 506 (should be v8, isn't it?)

if (strpos($line, '*/') === 0) {

should be changed to

if ((strpos($line, '*/') === 0) || (strripos($line, '*/') !== false)) {

Otherwise, multiline-comments only work if the ending */ is the first string/character group in the line.
Furthermore, this leads to a complete inactivation of every following TS-code (Extensions Templates or other stuff), as the following TypoScript is treated as part of the comment.

This solution checks the presence at the start (as before) and optionally checks for existance of an multiline-comment-ending-string, beginning the search at the end of the string.
Please beware of using an explicit position for the strripos() comparison with this technique, as there may be whitespace characters at the end (in this case, rtrim() is needed).

If this solution is not accepted, the syntax highlighting should be changed, as the commented section is still treated as a comment in the backend template editor, though the comment-end is not detected by this technique. Still, this needs to be verified and checked by somebody for possible problems created. My tests didn't result in any problems.

Actions #3

Updated by Bernd Wilke almost 8 years ago

problems could occur if you include other code (e.g. javascript) as typoscript data which uses the same character strings than typoscript.
so not only the usage of '{','}' is not unique, this might be also possible with '/*' and '*/'.

take the following example:

/* don't use the JS-init at the moment
page {
  JSinline = TEXT
  JSinline.value (
    var i = 1;
    $(document).ready(function () {
      /* init the page */
      $('.show').show();
    });
  )
}
*/

Actions #4

Updated by Bernd Wilke almost 8 years ago

just two other notices to this ticket:
1. it is documented that all comments beginning with an '/*' at the start of a line have to be closed with a '*/' at the start of a line (no comment-closing somewhere in or at the end of a line).
2. there might be a real error considering that an opened multi-line comment is not ended at the end of the current typoscript template (conditions are always ended at the end of a single template)

Actions #5

Updated by Benni Mack about 4 years ago

  • Related to Bug #41327: jsInline removes closing brackets added
Actions #6

Updated by Christian Kuhn over 1 year ago

Actions #7

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74987

Actions #8

Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74987

Actions #9

Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74987

Actions #10

Updated by Gerrit Code Review over 1 year ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74987

Actions #11

Updated by Christian Kuhn over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 90 to 100
Actions #12

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF