Limit maximum template render output to 256KiB (#124946)
* Limit maximum template render output to 256KiB fixes #124931 256KiB is likely to still block the event loop for an unreasonable amont of time but its likely someone is using the template engine for large blocks of data so we want a limit which still allows that but has a reasonable safety to prevent the system from crashing down * Update homeassistant/helpers/template.py
This commit is contained in:
@@ -6281,3 +6281,10 @@ def test_unzip(hass: HomeAssistant, col, expected) -> None:
|
||||
).async_render({"col": col})
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
def test_template_output_exceeds_maximum_size(hass: HomeAssistant) -> None:
|
||||
"""Test template output exceeds maximum size."""
|
||||
tpl = template.Template("{{ 'a' * 1024 * 257 }}", hass)
|
||||
with pytest.raises(TemplateError):
|
||||
tpl.async_render()
|
||||
|
||||
Reference in New Issue
Block a user