aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
diff options
context:
space:
mode:
authorNiels van Velzen <nielsvanvelzen@users.noreply.github.com>2024-09-24 08:37:35 +0200
committerGitHub <noreply@github.com>2024-09-24 08:37:35 +0200
commit30be00adb2f29a94b5175f52c16585e9b9d85527 (patch)
treed9591d96f92529dabc3438b8e4118c86499c53fc /MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
parentcb8f01065a03a5ba546c1ff33c7452d81c32da62 (diff)
parent0ffddacf11795b8a50606b6515c1dc6828ad8dd0 (diff)
Merge pull request #12698 from jellyfin/fix-libraryoptions-api
Sanitize CustomTagDelimiters server side
Diffstat (limited to 'MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs')
-rw-r--r--MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs b/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
new file mode 100644
index 000000000..4a814f22a
--- /dev/null
+++ b/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Linq;
+using MediaBrowser.Model.Configuration;
+
+namespace MediaBrowser.Model.Extensions;
+
+/// <summary>
+/// Extensions for <see cref="LibraryOptions"/>.
+/// </summary>
+public static class LibraryOptionsExtension
+{
+ /// <summary>
+ /// Get the custom tag delimiters.
+ /// </summary>
+ /// <param name="options">This LibraryOptions.</param>
+ /// <returns>CustomTagDelimiters in char[].</returns>
+ public static char[] GetCustomTagDelimiters(this LibraryOptions options)
+ {
+ ArgumentNullException.ThrowIfNull(options);
+
+ return options.CustomTagDelimiters.Select<string, char?>(x =>
+ {
+ var isChar = char.TryParse(x, out var c);
+ if (isChar)
+ {
+ return c;
+ }
+
+ return null;
+ }).Where(x => x is not null).Select(x => x!.Value).ToArray();
+ }
+}