Skip to content
Snippets Groups Projects
Commit 1604e6b3 authored by Simon Praetorius's avatar Simon Praetorius
Browse files

[FEATURE] Ignore Fluid syntax error in <f:comment>

This patch enables a template processor included in Fluid 4
for all Fluid instances in the Core. The template processor
strips `<f:comment>` tags from Fluid template strings before
the parsing starts. This prevents Fluid errors when invalid
Fluid code is used inside `<f:comment>`.

Original change in Fluid:
https://github.com/TYPO3/Fluid/commit/faad81a9f5d991d688e1d4c673e0d7aaf41a7e94

Resolves: #104904
Releases: main
Change-Id: Ieebb60ee21ae9f8d6f168e75b9fd22a7103a5f6a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86012


Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Tested-by: default avatarAndreas Kienast <a.fernandez@scripting-base.de>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarSimon Praetorius <simon@praetorius.me>
Reviewed-by: default avatarSimon Praetorius <simon@praetorius.me>
Reviewed-by: default avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarAndreas Kienast <a.fernandez@scripting-base.de>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarcore-ci <typo3@b13.com>
parent 365f1f54
Branches
Tags
No related merge requests found
......@@ -364,6 +364,7 @@ return [
\TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\EscapingModifierTemplateProcessor::class,
\TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\PassthroughSourceModifierTemplateProcessor::class,
\TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor::class,
\TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\RemoveCommentsTemplateProcessor::class,
],
'expressionNodeTypes' => [
\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\CastingExpressionNode::class,
......
.. include:: /Includes.rst.txt
.. _feature-104904-1726049662:
===========================================================
Feature: #104904 - Ignore Fluid syntax error in <f:comment>
===========================================================
See :issue:`104904`
Description
===========
Fluid 4 brings a new template processor
:php:`TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\RemoveCommentsTemplateProcessor`
which removes Fluid comments created with :html:`<f:comment>` from the template source
string before the parsing process starts. It retains the original line breaks to ensure
that error messages still refer to the correct line in the template.
By applying this template processor to all Fluid instances in the Core, it is now
possible to use invalid Fluid code inside :html:`<f:comment>` without triggering a Fluid error.
Impact
======
This feature is helpful during template development because developers don't need to
take care for commented-out code being valid Fluid code.
.. index:: Fluid, ext:fluid
......@@ -27,6 +27,7 @@ use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\EscapingModifierTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\PassthroughSourceModifierTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\RemoveCommentsTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessorInterface;
/**
......@@ -68,6 +69,7 @@ final readonly class RenderingContextFactory
new EscapingModifierTemplateProcessor(),
new PassthroughSourceModifierTemplateProcessor(),
new NamespaceDetectionTemplateProcessor(),
new RemoveCommentsTemplateProcessor(),
];
} else {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['preProcessors'] as $className) {
......
......@@ -39,3 +39,7 @@ services:
TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor:
public: true
shared: false
TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\RemoveCommentsTemplateProcessor:
public: true
shared: false
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment