From a9865367d8aec1bd323680a3440427dfaac2a89b Mon Sep 17 00:00:00 2001 From: Tim Eisele Date: Tue, 12 May 2026 18:12:54 +0200 Subject: Safeguard against invalid GUIDs (#16813) Safeguard against invalid GUIDs --- MediaBrowser.Controller/IO/IPathManager.cs | 16 ++++++++-------- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/IO/IPathManager.cs b/MediaBrowser.Controller/IO/IPathManager.cs index eb67437545..30961c7610 100644 --- a/MediaBrowser.Controller/IO/IPathManager.cs +++ b/MediaBrowser.Controller/IO/IPathManager.cs @@ -22,30 +22,30 @@ public interface IPathManager /// The media source id. /// The stream index. /// The subtitle file extension. - /// The absolute path. - public string GetSubtitlePath(string mediaSourceId, int streamIndex, string extension); + /// The absolute path, or null if is not a valid GUID. + public string? GetSubtitlePath(string mediaSourceId, int streamIndex, string extension); /// /// Gets the path to the subtitle file. /// /// The media source id. - /// The absolute path. - public string GetSubtitleFolderPath(string mediaSourceId); + /// The absolute path, or null if is not a valid GUID. + public string? GetSubtitleFolderPath(string mediaSourceId); /// /// Gets the path to the attachment file. /// /// The media source id. /// The attachmentFileName index. - /// The absolute path. - public string GetAttachmentPath(string mediaSourceId, string fileName); + /// The absolute path, or null if is not a valid GUID. + public string? GetAttachmentPath(string mediaSourceId, string fileName); /// /// Gets the path to the attachment folder. /// /// The media source id. - /// The absolute path. - public string GetAttachmentFolderPath(string mediaSourceId); + /// The absolute path, or null if is not a valid GUID. + public string? GetAttachmentFolderPath(string mediaSourceId); /// /// Gets the chapter images data path. diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 04b13a6f3c..0eeb9e632c 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1880,10 +1880,12 @@ namespace MediaBrowser.Controller.MediaEncoding var sub2videoParam = enableSub2video ? ":sub2video=1" : string.Empty; var fontPath = _pathManager.GetAttachmentFolderPath(state.MediaSource.Id); - var fontParam = string.Format( - CultureInfo.InvariantCulture, - ":fontsdir='{0}'", - _mediaEncoder.EscapeSubtitleFilterPath(fontPath)); + var fontParam = fontPath is null + ? string.Empty + : string.Format( + CultureInfo.InvariantCulture, + ":fontsdir='{0}'", + _mediaEncoder.EscapeSubtitleFilterPath(fontPath)); if (state.SubtitleStream.IsExternal) { -- cgit v1.2.3