aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/StreamingHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Api/Helpers/StreamingHelpers.cs')
-rw-r--r--Jellyfin.Api/Helpers/StreamingHelpers.cs27
1 files changed, 19 insertions, 8 deletions
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index 1e984542ec..bae2756303 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -17,9 +17,7 @@ using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Streaming;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.Net.Http.Headers;
namespace Jellyfin.Api.Helpers;
@@ -268,7 +266,7 @@ public static class StreamingHelpers
Dictionary<string, string?> streamOptions = new Dictionary<string, string?>();
foreach (var param in queryString)
{
- if (char.IsLower(param.Key[0]))
+ if (param.Key.Length > 0 && char.IsLower(param.Key[0]))
{
// This was probably not parsed initially and should be a StreamOptions
// or the generated URL should correctly serialize it
@@ -422,14 +420,18 @@ public static class StreamingHelpers
request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
break;
case 4:
- if (videoRequest is not null)
+ if (videoRequest is not null && IsValidCodecName(val))
{
videoRequest.VideoCodec = val;
}
break;
case 5:
- request.AudioCodec = val;
+ if (IsValidCodecName(val))
+ {
+ request.AudioCodec = val;
+ }
+
break;
case 6:
if (videoRequest is not null)
@@ -483,7 +485,7 @@ public static class StreamingHelpers
request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture);
break;
case 15:
- if (videoRequest is not null)
+ if (videoRequest is not null && EncodingHelper.LevelValidationRegex().IsMatch(val))
{
videoRequest.Level = val;
}
@@ -504,7 +506,7 @@ public static class StreamingHelpers
break;
case 18:
- if (videoRequest is not null)
+ if (videoRequest is not null && IsValidCodecName(val))
{
videoRequest.Profile = val;
}
@@ -563,7 +565,11 @@ public static class StreamingHelpers
break;
case 30:
- request.SubtitleCodec = val;
+ if (IsValidCodecName(val))
+ {
+ request.SubtitleCodec = val;
+ }
+
break;
case 31:
if (videoRequest is not null)
@@ -586,6 +592,11 @@ public static class StreamingHelpers
}
}
+ private static bool IsValidCodecName(string val)
+ {
+ return EncodingHelper.ContainerValidationRegex().IsMatch(val);
+ }
+
/// <summary>
/// Parses the container into its file extension.
/// </summary>