From cf67381e310789f5c2f594b51c6170cf7e9019d0 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 8 Nov 2022 21:13:57 +0100 Subject: [PATCH] Fix release build --- Emby.Dlna/DlnaManager.cs | 8 +++++++- Emby.Dlna/IDlnaEventManager.cs | 1 + Emby.Dlna/Service/BaseService.cs | 1 + Jellyfin.Api/Controllers/ImageController.cs | 11 +++++++++-- Jellyfin.Api/Helpers/StreamingHelpers.cs | 4 ++-- .../Extensions/ConfigurationExtensions.cs | 8 ++++---- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index f23c5f970c..99b3e6e7ef 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -199,6 +199,11 @@ namespace Emby.Dlna if (headers.TryGetValue(header.Name, out StringValues value)) { + if (StringValues.IsNullOrEmpty(value)) + { + return false; + } + switch (header.Match) { case HeaderMatchType.Equals: @@ -208,7 +213,8 @@ namespace Emby.Dlna // _logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch); return isMatch; case HeaderMatchType.Regex: - return Regex.IsMatch(value, header.Value, RegexOptions.IgnoreCase); + // Can't be null, we checked above the switch statement + return Regex.IsMatch(value!, header.Value, RegexOptions.IgnoreCase); default: throw new ArgumentException("Unrecognized HeaderMatchType"); } diff --git a/Emby.Dlna/IDlnaEventManager.cs b/Emby.Dlna/IDlnaEventManager.cs index eea030d6d1..bb1eeb963d 100644 --- a/Emby.Dlna/IDlnaEventManager.cs +++ b/Emby.Dlna/IDlnaEventManager.cs @@ -1,3 +1,4 @@ +#nullable disable #pragma warning disable CS1591 namespace Emby.Dlna diff --git a/Emby.Dlna/Service/BaseService.cs b/Emby.Dlna/Service/BaseService.cs index 68fd987585..67e7bf6a63 100644 --- a/Emby.Dlna/Service/BaseService.cs +++ b/Emby.Dlna/Service/BaseService.cs @@ -1,3 +1,4 @@ +#nullable disable #pragma warning disable CS1591 using System.Net.Http; diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs index 260b9536e3..49342ad5ce 100644 --- a/Jellyfin.Api/Controllers/ImageController.cs +++ b/Jellyfin.Api/Controllers/ImageController.cs @@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; namespace Jellyfin.Api.Controllers @@ -2026,8 +2027,13 @@ namespace Jellyfin.Api.Controllers } var acceptParam = Request.Query[HeaderNames.Accept]; + if (StringValues.IsNullOrEmpty(acceptParam)) + { + return Array.Empty(); + } - var supportsWebP = SupportsFormat(supportedFormats, acceptParam, ImageFormat.Webp, false); + // Can't be null, checked above + var supportsWebP = SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Webp, false); if (!supportsWebP) { @@ -2049,7 +2055,8 @@ namespace Jellyfin.Api.Controllers formats.Add(ImageFormat.Jpg); formats.Add(ImageFormat.Png); - if (SupportsFormat(supportedFormats, acceptParam, ImageFormat.Gif, true)) + // Can't be null, checked above + if (SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Gif, true)) { formats.Add(ImageFormat.Gif); } diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index 1decbcd923..d4fc9c020a 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -364,9 +364,9 @@ namespace Jellyfin.Api.Helpers /// /// The query string. /// A containing the stream options. - private static Dictionary ParseStreamOptions(IQueryCollection queryString) + private static Dictionary ParseStreamOptions(IQueryCollection queryString) { - Dictionary streamOptions = new Dictionary(); + Dictionary streamOptions = new Dictionary(); foreach (var param in queryString) { if (char.IsLower(param.Key[0])) diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs index 5a71102617..3b5e8ece71 100644 --- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs +++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Extensions /// /// The configuration to read the setting from. /// The FFmpeg probe size option. - public static string GetFFmpegProbeSize(this IConfiguration configuration) + public static string? GetFFmpegProbeSize(this IConfiguration configuration) => configuration[FfmpegProbeSizeKey]; /// @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Extensions /// /// The configuration to read the setting from. /// The FFmpeg analyze duration option. - public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration) + public static string? GetFFmpegAnalyzeDuration(this IConfiguration configuration) => configuration[FfmpegAnalyzeDurationKey]; /// @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Extensions /// /// The configuration to read the setting from. /// The unix socket path. - public static string GetUnixSocketPath(this IConfiguration configuration) + public static string? GetUnixSocketPath(this IConfiguration configuration) => configuration[UnixSocketPathKey]; /// @@ -113,7 +113,7 @@ namespace MediaBrowser.Controller.Extensions /// /// The configuration to read the setting from. /// The unix socket permissions. - public static string GetUnixSocketPermissions(this IConfiguration configuration) + public static string? GetUnixSocketPermissions(this IConfiguration configuration) => configuration[UnixSocketPermissionsKey]; } }