Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Core/Parser/SyntaxTree/ObjectAccessorNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\Variables\InvalidVariableIdentifierException;

/**
* A node which handles object access. This means it handles structures like {object.accessor.bla}
Expand All @@ -34,6 +35,12 @@ final class ObjectAccessorNode extends AbstractNode
*/
public function __construct(string $objectPath)
{
// TODO consider removing this exception in later Fluid versions. For now it allows the
// TemplateValidator to find occurrances of variables starting with "_" in templates,
// which are no longer allowed since Fluid 5.
if (str_starts_with($objectPath, '_') && $objectPath !== '_all') {
throw new InvalidVariableIdentifierException('Variable identifiers cannot start with a "_": ' . $objectPath, 1765900762);
}
$this->objectPath = $objectPath;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{_something.sub}
1 change: 1 addition & 0 deletions tests/Functional/Validation/TemplateValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static function validatorFindsParseErrorsDataProvider(): array
[$fixturePath . 'InvalidNamespace.fluid.html', 'Unknown Namespace: foo', 0],
[$fixturePath . 'RequiredArgumentMissing.fluid.html', 'Required argument "each" was not supplied.', 1237823699],
[$fixturePath . 'RedefinedComponentArgument.fluid.html', 'Template argument "foo" has been defined multiple times.', 1744908509],
[$fixturePath . 'AccessToInvalidVariableName.fluid.html', 'Variable identifiers cannot start with a "_": _something.sub', 1765900762],
];
}

Expand Down