Catch HTML case insensitively in "no HTML" config validation (#101181)
This commit is contained in:
parent
a3808383d5
commit
f4bf8fa8f1
3 changed files with 5 additions and 2 deletions
|
@ -11,7 +11,7 @@
|
||||||
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
|
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
|
||||||
},
|
},
|
||||||
"create_entry": {
|
"create_entry": {
|
||||||
"default": "\n\nOn Android, open [the OwnTracks app]({android_url}), go to Preferences > Connection. Change the following settings:\n - Mode: HTTP\n - Host: {webhook_url}\n - Identification:\n - Username: `'<Your name>'`\n - Device ID: `'<Your device name>'`\n\nOn iOS, open [the OwnTracks app]({ios_url}), tap (i) icon in top left > Settings. Change the following settings:\n - Mode: HTTP\n - URL: {webhook_url}\n - Turn on authentication\n - UserID: `'<Your name>'`\n\n{secret}\n\nSee [the documentation]({docs_url}) for more information."
|
"default": "\n\nOn Android, open [the OwnTracks app]({android_url}), go to Preferences > Connection. Change the following settings:\n - Mode: HTTP\n - Host: {webhook_url}\n - Identification:\n - Username: `'(Your name)'`\n - Device ID: `'(Your device name)'`\n\nOn iOS, open [the OwnTracks app]({ios_url}), tap (i) icon in top left > Settings. Change the following settings:\n - Mode: HTTP\n - URL: {webhook_url}\n - Turn on authentication\n - UserID: `'(Your name)'`\n\n{secret}\n\nSee [the documentation]({docs_url}) for more information."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ def string(value: Any) -> str:
|
||||||
def string_with_no_html(value: Any) -> str:
|
def string_with_no_html(value: Any) -> str:
|
||||||
"""Validate that the value is a string without HTML."""
|
"""Validate that the value is a string without HTML."""
|
||||||
value = string(value)
|
value = string(value)
|
||||||
regex = re.compile(r"<[a-z][\s\S]*>")
|
regex = re.compile(r"<[a-z].*?>", re.IGNORECASE)
|
||||||
if regex.search(value):
|
if regex.search(value):
|
||||||
raise vol.Invalid("the string should not contain HTML")
|
raise vol.Invalid("the string should not contain HTML")
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
|
@ -563,6 +563,9 @@ def test_string_with_no_html() -> None:
|
||||||
with pytest.raises(vol.Invalid):
|
with pytest.raises(vol.Invalid):
|
||||||
schema("<b>Bold</b>")
|
schema("<b>Bold</b>")
|
||||||
|
|
||||||
|
with pytest.raises(vol.Invalid):
|
||||||
|
schema("HTML element names are <EM>case-insensitive</eM>.")
|
||||||
|
|
||||||
for value in (
|
for value in (
|
||||||
True,
|
True,
|
||||||
3,
|
3,
|
||||||
|
|
Loading…
Add table
Reference in a new issue