mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Guard against non http schemes (#69938)
This commit is contained in:
parent
d57863946d
commit
f6a3598070
@ -32,6 +32,9 @@ def async_process_play_media_url(
|
|||||||
"""Update a media URL with authentication if it points at Home Assistant."""
|
"""Update a media URL with authentication if it points at Home Assistant."""
|
||||||
parsed = yarl.URL(media_content_id)
|
parsed = yarl.URL(media_content_id)
|
||||||
|
|
||||||
|
if parsed.scheme and parsed.scheme not in ("http", "https"):
|
||||||
|
return media_content_id
|
||||||
|
|
||||||
if parsed.is_absolute():
|
if parsed.is_absolute():
|
||||||
if not is_hass_url(hass, media_content_id):
|
if not is_hass_url(hass, media_content_id):
|
||||||
return media_content_id
|
return media_content_id
|
||||||
|
@ -36,6 +36,11 @@ async def test_process_play_media_url(hass, mock_sign_path):
|
|||||||
async_process_play_media_url(hass, "https://not-hass.com/path")
|
async_process_play_media_url(hass, "https://not-hass.com/path")
|
||||||
== "https://not-hass.com/path"
|
== "https://not-hass.com/path"
|
||||||
)
|
)
|
||||||
|
# Not changing a url that is not http/https
|
||||||
|
assert (
|
||||||
|
async_process_play_media_url(hass, "file:///tmp/test.mp3")
|
||||||
|
== "file:///tmp/test.mp3"
|
||||||
|
)
|
||||||
|
|
||||||
# Testing signing hass URLs
|
# Testing signing hass URLs
|
||||||
assert (
|
assert (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user