Add check for HTML in translations (#35615)

* Add check for HTML in translations

and remove existing html

* Add test
This commit is contained in:
Bram Kragten 2020-05-14 19:33:14 +02:00 committed by GitHub
parent a42a654590
commit cb7b8d94c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 18 deletions

View file

@ -351,6 +351,26 @@ def test_string():
schema(value)
def test_string_with_no_html():
"""Test string with no html validation."""
schema = vol.Schema(cv.string_with_no_html)
with pytest.raises(vol.Invalid):
schema("This has HTML in it <a>Link</a>")
with pytest.raises(vol.Invalid):
schema("<b>Bold</b>")
for value in (
True,
3,
"Hello",
"**Hello**",
"This has no HTML [Link](https://home-assistant.io)",
):
schema(value)
def test_temperature_unit():
"""Test temperature unit validation."""
schema = vol.Schema(cv.temperature_unit)