Catch HTML case insensitively in "no HTML" config validation (#101181)

This commit is contained in:
Ville Skyttä 2023-10-01 17:19:24 +03:00 committed by GitHub
parent a3808383d5
commit f4bf8fa8f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View file

@ -599,7 +599,7 @@ def string(value: Any) -> str:
def string_with_no_html(value: Any) -> str:
"""Validate that the value is a string without HTML."""
value = string(value)
regex = re.compile(r"<[a-z][\s\S]*>")
regex = re.compile(r"<[a-z].*?>", re.IGNORECASE)
if regex.search(value):
raise vol.Invalid("the string should not contain HTML")
return str(value)