mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix external internal url core check (#54310)
This commit is contained in:
parent
952d11cb03
commit
a1abd4f0d6
@ -1723,13 +1723,13 @@ class Config:
|
|||||||
|
|
||||||
# In 2021.9 we fixed validation to disallow a path (because that's never correct)
|
# In 2021.9 we fixed validation to disallow a path (because that's never correct)
|
||||||
# but this data still lives in storage, so we print a warning.
|
# but this data still lives in storage, so we print a warning.
|
||||||
if "external_url" in data and urlparse(data["external_url"]).path not in (
|
if data.get("external_url") and urlparse(data["external_url"]).path not in (
|
||||||
"",
|
"",
|
||||||
"/",
|
"/",
|
||||||
):
|
):
|
||||||
_LOGGER.warning("Invalid external_url set. It's not allowed to have a path")
|
_LOGGER.warning("Invalid external_url set. It's not allowed to have a path")
|
||||||
|
|
||||||
if "internal_url" in data and urlparse(data["internal_url"]).path not in (
|
if data.get("internal_url") and urlparse(data["internal_url"]).path not in (
|
||||||
"",
|
"",
|
||||||
"/",
|
"/",
|
||||||
):
|
):
|
||||||
|
@ -1377,6 +1377,18 @@ async def test_additional_data_in_core_config(hass, hass_storage):
|
|||||||
async def test_incorrect_internal_external_url(hass, hass_storage, caplog):
|
async def test_incorrect_internal_external_url(hass, hass_storage, caplog):
|
||||||
"""Test that we warn when detecting invalid internal/extenral url."""
|
"""Test that we warn when detecting invalid internal/extenral url."""
|
||||||
config = ha.Config(hass)
|
config = ha.Config(hass)
|
||||||
|
|
||||||
|
hass_storage[ha.CORE_STORAGE_KEY] = {
|
||||||
|
"version": 1,
|
||||||
|
"data": {
|
||||||
|
"internal_url": None,
|
||||||
|
"external_url": None,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
await config.async_load()
|
||||||
|
assert "Invalid external_url set" not in caplog.text
|
||||||
|
assert "Invalid internal_url set" not in caplog.text
|
||||||
|
|
||||||
hass_storage[ha.CORE_STORAGE_KEY] = {
|
hass_storage[ha.CORE_STORAGE_KEY] = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"data": {
|
"data": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user