aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgnattu <gnattuoc@me.com>2024-09-24 05:15:46 +0800
committergnattu <gnattuoc@me.com>2024-09-24 05:15:46 +0800
commit00ca4abbe1138d880fca36e1f99da14e6fab252a (patch)
tree8b1c7bd2a6d79bd2252e80aa5682f446f384a821
parentcb8f01065a03a5ba546c1ff33c7452d81c32da62 (diff)
Sanitize CustomTagDelimiters server side
The API requires an array type and does not support runtime generated default value. Use server side helper function to sanitize it into char.
-rw-r--r--MediaBrowser.Model/Configuration/LibraryOptions.cs20
-rw-r--r--MediaBrowser.Providers/MediaInfo/AudioFileProber.cs6
2 files changed, 20 insertions, 6 deletions
diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs
index 04283cc9e..b0fcc2d0a 100644
--- a/MediaBrowser.Model/Configuration/LibraryOptions.cs
+++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs
@@ -2,12 +2,13 @@
using System;
using System.ComponentModel;
+using System.Linq;
namespace MediaBrowser.Model.Configuration
{
public class LibraryOptions
{
- private static readonly char[] _defaultTagDelimiters = ['/', '|', ';', '\\'];
+ private static readonly string[] _defaultTagDelimiters = ["/", "|", ";", "\\"];
public LibraryOptions()
{
@@ -126,8 +127,7 @@ namespace MediaBrowser.Model.Configuration
[DefaultValue(false)]
public bool UseCustomTagDelimiters { get; set; }
- [DefaultValue(typeof(LibraryOptions), nameof(_defaultTagDelimiters))]
- public char[] CustomTagDelimiters { get; set; }
+ public string[] CustomTagDelimiters { get; set; }
public string[] DelimiterWhitelist { get; set; }
@@ -149,5 +149,19 @@ namespace MediaBrowser.Model.Configuration
return null;
}
+
+ public char[] GetCustomTagDelimiters()
+ {
+ return 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();
+ }
}
}
diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
index 80bb1a514..2e0d21c6a 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
@@ -178,7 +178,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (libraryOptions.UseCustomTagDelimiters)
{
- albumArtists = albumArtists.SelectMany(a => SplitWithCustomDelimiter(a, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray();
+ albumArtists = albumArtists.SelectMany(a => SplitWithCustomDelimiter(a, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray();
}
foreach (var albumArtist in albumArtists)
@@ -210,7 +210,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (libraryOptions.UseCustomTagDelimiters)
{
- performers = performers.SelectMany(p => SplitWithCustomDelimiter(p, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray();
+ performers = performers.SelectMany(p => SplitWithCustomDelimiter(p, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray();
}
foreach (var performer in performers)
@@ -313,7 +313,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (libraryOptions.UseCustomTagDelimiters)
{
- genres = genres.SelectMany(g => SplitWithCustomDelimiter(g, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray();
+ genres = genres.SelectMany(g => SplitWithCustomDelimiter(g, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray();
}
audio.Genres = options.ReplaceAllMetadata || audio.Genres is null || audio.Genres.Length == 0