Bug #76447
closedTypoScript Parse Bug
100%
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)
Updated by Markus Klein over 8 years ago
Maybe Elmar can take a look at this, he invested some time in this area recently.
Updated by Kevin Dargel over 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.
Updated by Bernd Wilke over 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(); }); ) } */
Updated by Bernd Wilke over 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)
Updated by Benni Mack over 4 years ago
- Related to Bug #41327: jsInline removes closing brackets added
Updated by Christian Kuhn over 2 years ago
- Related to Feature #97816: New TypoScript parser added
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Christian Kuhn over 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 90 to 100
Applied in changeset 09c61884bf2f15b0f209f8b177268620fc77cc8a.