mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Optimize template sandbox for Home Assistant (#39731)
This commit is contained in:
parent
12cc158b64
commit
2e6cd4f12b
@ -1122,7 +1122,13 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
|||||||
|
|
||||||
def is_safe_attribute(self, obj, attr, value):
|
def is_safe_attribute(self, obj, attr, value):
|
||||||
"""Test if attribute is safe."""
|
"""Test if attribute is safe."""
|
||||||
return isinstance(obj, Namespace) or super().is_safe_attribute(obj, attr, value)
|
if isinstance(obj, Namespace):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if isinstance(obj, (AllStates, DomainStates, TemplateState)):
|
||||||
|
return not attr.startswith("_")
|
||||||
|
|
||||||
|
return super().is_safe_attribute(obj, attr, value)
|
||||||
|
|
||||||
def compile(self, source, name=None, filename=None, raw=False, defer_init=False):
|
def compile(self, source, name=None, filename=None, raw=False, defer_init=False):
|
||||||
"""Compile the template."""
|
"""Compile the template."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user