@@ -576,23 +576,30 @@ def visit_FormattedValue(self, node: ast.FormattedValue) -> ast.AST:
576576 return self .node_contents_visit (node )
577577
578578 def visit_TemplateStr (self , node : ast .AST ) -> ast .AST :
579- """Allow template strings without restrictions.
580-
581- TODO: Review security implications of template strings.
579+ """Template strings are not allowed by default.
580+ Even so, that template strings can be useful in context of Template Engines
581+ A Template String itself is not executed itself, but it contain expressions
582+ and need additional template rendering logic applied to it to be useful.
583+ Those rendering logic would be affected by RestrictedPython as well.
584+
585+ TODO: Deeper review of security implications of template strings.
582586 TODO: Change Type Annotation to ast.TemplateStr when
583587 Support for Python 3.13 is dropped.
584588 """
585- return self .not_allowed (node )
589+ self .warn (node , 'TemplateStr statements are not yet allowed, please use f-strings or a real template engine instead.' )
590+ self .not_allowed (node )
586591 # return self.node_contents_visit(node)
587592
588- def visit_InterpolatedStr (self , node : ast .AST ) -> ast .AST :
589- """Allow interpolated strings without restrictions.
590-
591- TODO: Review security implications of interpolated strings.
592- TODO: Change Type Annotation to ast.InterpolatedStr when
593+ def visit_Interpolation (self , node : ast .AST ) -> ast .AST :
594+ """Interpolations are not allowed by default.
595+ As Interpolations are part of Template Strings, they will not be reached in
596+ context of RestrictedPython as Template Strings are not allowed.
597+
598+ TODO: Deeper review of security implications of interpolated strings.
599+ TODO: Change Type Annotation to ast.Interpolation when
593600 Support for Python 3.13 is dropped.
594601 """
595- return self .not_allowed (node )
602+ self .not_allowed (node )
596603 # return self.node_contents_visit(node)
597604
598605 def visit_JoinedStr (self , node : ast .JoinedStr ) -> ast .AST :
0 commit comments