Changes to filename and path validation (#45529)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
4739e8a207
commit
b1c2cde40b
10 changed files with 127 additions and 19 deletions
|
@ -87,7 +87,7 @@ from homeassistant.helpers import (
|
|||
template as template_helper,
|
||||
)
|
||||
from homeassistant.helpers.logging import KeywordStyleAdapter
|
||||
from homeassistant.util import sanitize_path, slugify as util_slugify
|
||||
from homeassistant.util import raise_if_invalid_path, slugify as util_slugify
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
@ -118,8 +118,10 @@ def path(value: Any) -> str:
|
|||
if not isinstance(value, str):
|
||||
raise vol.Invalid("Expected a string")
|
||||
|
||||
if sanitize_path(value) != value:
|
||||
raise vol.Invalid("Invalid path")
|
||||
try:
|
||||
raise_if_invalid_path(value)
|
||||
except ValueError as err:
|
||||
raise vol.Invalid("Invalid path") from err
|
||||
|
||||
return value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue