Bug #99503
closedInline script concatenation requires scripts to have trailing ";"
100%
Description
concatenateJs produces invalid JavaScript if scripts do not end with ';'.
In JavaScript ';' line endings are optional, but when concatenating scripts a ';' (or a line feed) needs to be added.
Minimum reproducible example:
(TypoScript settings)
config.concatenateJs = 1 page.jsInline { script1 = TEXT script1.value = alert(1) script2 = TEXT script2.value = alert(2) }
This results in
alert(1)alert(2)
(This applies to concatenated files in any of the PAGE.includeJS functions and friends, too)
Updated by Jonas Eberle over 1 year ago
Correction: it seems string keys are not possible there.
So the MRE is:
config.concatenateJs = 1 page.jsInline { 10 = TEXT 10.value = alert(1) 20 = TEXT 20.value = alert(2) }
Updated by Jonas Eberle over 1 year ago
My debugging went as far as to understand that page.jsInline is quite different from the others like page.includeJS.
page.jsInline renders no separators because it gets handed to \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::cObjGet directly.
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 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/+/77320
Updated by Jonas Eberle over 1 year ago
- Subject changed from config.concatenateJs requires scripts to finish with ";" to Inline script concatenation requires scripts to have trailing ";"
Updated by Gerrit Code Review over 1 year ago
Patch set 2 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/+/77320
Updated by Gerrit Code Review about 1 year ago
Patch set 3 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/+/77320
Updated by Gerrit Code Review about 1 year ago
Patch set 4 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/+/77320
Updated by Gerrit Code Review about 1 year ago
Patch set 5 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/+/77320
Updated by Gerrit Code Review 9 months ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81686
Updated by Gerrit Code Review 9 months ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81687
Updated by Gerrit Code Review 9 months ago
Patch set 2 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81686
Updated by Anonymous 9 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 52795f16b592f3c1e8d76c4ca99dd12f4ea21609.
Updated by Rafael Kähm 9 months ago
Please reopen, because applied patch makes unnecessary BC at least on 11.5.
See:
public function cObjGet($setup, $addKey = '')
{
return implode('', $this->cObjGetSeparated($setup, $addKey));
}
public function cObjGetSeparated(?array $setup, string $addKey = ''): array
{
if (!is_array($setup) || $setup === []) {
return [];
}
Proposal:
public function cObjGet($setup, $addKey = '')
{
if (!is_array($setup)) {
return '';
}
return implode('', $this->cObjGetSeparated($setup, $addKey));
}
public function cObjGetSeparated(?array $setup = [], string $addKey = ''): array
{
if (empty($setup)) {
return [];
}
Updated by Jonas Eberle 9 months ago
Do you mean it became stricter? I agree, and I am sorry I have not noticed that. Before, it would return '' when given anything but an array.
Sorry, what is "BC"?
Updated by Benjamin Franzke 9 months ago
- Related to Bug #102328: Regression in cObjGet added
Updated by Benjamin Franzke 9 months ago
Thanks for the report Rafael.
Please find a fix in:
81698: [BUGFIX] Fix possible regression in cObjGet() | https://review.typo3.org/c/Packages/TYPO3.CMS/+/81698