mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Generic camera: Allow svg detect to accept leading whitespace (#68932)
This commit is contained in:
parent
d25f7e1376
commit
3244980a35
@ -114,7 +114,7 @@ def get_image_type(image):
|
||||
if fmt is None:
|
||||
# if imghdr can't figure it out, could be svg.
|
||||
with contextlib.suppress(UnicodeDecodeError):
|
||||
if image.decode("utf-8").startswith("<svg"):
|
||||
if image.decode("utf-8").lstrip().startswith("<svg"):
|
||||
return "svg+xml"
|
||||
return fmt
|
||||
|
||||
|
@ -110,6 +110,21 @@ async def test_form_only_stillimage(hass, fakeimg_png, user_flow):
|
||||
assert respx.calls.call_count == 1
|
||||
|
||||
|
||||
@respx.mock
|
||||
async def test_form_only_svg_whitespace(hass, fakeimgbytes_svg, user_flow):
|
||||
"""Test we complete ok if svg starts with whitespace, issue #68889."""
|
||||
fakeimgbytes_wspace_svg = bytes(" \n ", encoding="utf-8") + fakeimgbytes_svg
|
||||
respx.get("http://127.0.0.1/testurl/1").respond(stream=fakeimgbytes_wspace_svg)
|
||||
|
||||
data = TESTDATA.copy()
|
||||
data.pop(CONF_STREAM_SOURCE)
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
user_flow["flow_id"],
|
||||
data,
|
||||
)
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
|
||||
@respx.mock
|
||||
async def test_form_rtsp_mode(hass, fakeimg_png, mock_av_open, user_flow):
|
||||
"""Test we complete ok if the user enters a stream url."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user