From 4ec187d17b6ab4f9cbdd6ab1ecc2cceed4354743 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 1 Oct 2024 20:04:59 -0400 Subject: [PATCH] validate data before sending to isLocalHost() to prevent app crash --- components/ItemGrid/LoadVideoContentTask.bs | 8 ++++++-- source/VideoPlayer.bs | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/ItemGrid/LoadVideoContentTask.bs b/components/ItemGrid/LoadVideoContentTask.bs index 643df4fe..7a865db1 100644 --- a/components/ItemGrid/LoadVideoContentTask.bs +++ b/components/ItemGrid/LoadVideoContentTask.bs @@ -350,11 +350,15 @@ sub addVideoContentURL(video, mediaSourceId, audio_stream_idx, fully_external) protocol = LCase(m.playbackInfo.MediaSources[0].Protocol) if protocol <> "file" uri = parseUrl(m.playbackInfo.MediaSources[0].Path) - if isLocalhost(uri[2]) + if not isValidAndNotEmpty(uri) then return + + if isValid(uri[2]) and isLocalhost(uri[2]) ' if the domain of the URI is local to the server, ' create a new URI by appending the received path to the server URL ' later we will substitute the users provided URL for this case - video.content.url = buildURL(uri[4]) + if isValid(uri[4]) + video.content.url = buildURL(uri[4]) + end if else fully_external = true video.content.url = m.playbackInfo.MediaSources[0].Path diff --git a/source/VideoPlayer.bs b/source/VideoPlayer.bs index 1c4f7e75..97a93fa6 100644 --- a/source/VideoPlayer.bs +++ b/source/VideoPlayer.bs @@ -263,16 +263,20 @@ sub AddVideoContent(video as object, mediaSourceId as dynamic, audio_stream_idx protocol = LCase(m.playbackInfo.MediaSources[0].Protocol) if protocol <> "file" uri = parseUrl(m.playbackInfo.MediaSources[0].Path) - if isLocalhost(uri[2]) + if not isValidAndNotEmpty(uri) then return + + if isValid(uri[2]) and isLocalhost(uri[2]) ' the domain of the URI is local to the server. ' create a new URI by appending the received path to the server URL ' later we will substitute the users provided URL for this case - video.content.url = buildURL(uri[4]) + if isValid(uri[4]) + video.content.url = buildURL(uri[4]) + end if else fully_external = true video.content.url = m.playbackInfo.MediaSources[0].Path end if - else: + else params.append({ "Static": "true", "Container": video.container,