From d7f4f5cbcc0aa960d1686232f6852f6ef7316f47 Mon Sep 17 00:00:00 2001
From: wolffshots <16850875+wolffshots@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:37:54 +0200
Subject: [PATCH] chore: explicitly handle null description
---
.../Utils/Utils.cs | 33 +++++++++----------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs
index f00a9d2..12add7a 100644
--- a/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs
+++ b/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs
@@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
{
@@ -42,27 +43,25 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
/// A string with \n replaced by br tags.
public static string FormatDescription(string description)
{
- try
+ if (description == null)
{
- var maxLength = 500;
- if (Plugin.Instance != null)
- {
- maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
- }
-
- if (description.Length > maxLength)
- {
- description = description.Substring(0, maxLength);
- }
-
- description = description.Replace("\n", "
", System.StringComparison.CurrentCulture);
-
- return description;
+ return "Description is null";
}
- catch (Exception)
+
+ var maxLength = 500;
+ if (Plugin.Instance != null)
{
- return "Error getting description";
+ maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
}
+
+ if (description.Length > maxLength)
+ {
+ description = description.Substring(0, maxLength);
+ }
+
+ description = description.Replace("\n", "
", System.StringComparison.CurrentCulture);
+
+ return description;
}
///