Guard against non http schemes (#69938)
This commit is contained in:
parent
d57863946d
commit
f6a3598070
2 changed files with 8 additions and 0 deletions
|
@ -32,6 +32,9 @@ def async_process_play_media_url(
|
|||
"""Update a media URL with authentication if it points at Home Assistant."""
|
||||
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 not is_hass_url(hass, 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")
|
||||
== "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
|
||||
assert (
|
||||
|
|
Loading…
Add table
Reference in a new issue