diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs index 9cb49c471..07b86c7fa 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs @@ -1889,7 +1889,7 @@ namespace Dalamud.Interface.Internal.Windows return hasSearchString && !( manifest.Name.ToLowerInvariant().Contains(searchString) || - manifest.Author.Equals(this.searchText, StringComparison.InvariantCultureIgnoreCase) || + (!manifest.Author.IsNullOrEmpty() && manifest.Author.Equals(this.searchText, StringComparison.InvariantCultureIgnoreCase)) || (manifest.Tags != null && manifest.Tags.Contains(searchString, StringComparer.InvariantCultureIgnoreCase))); } diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 423fba98f..d7ef38f05 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -247,9 +247,9 @@ namespace Dalamud.Plugin.Internal { // Not a plugin } - catch (Exception) + catch (Exception ex) { - Log.Error("During boot plugin load, an unexpected error occurred"); + Log.Error(ex, "During boot plugin load, an unexpected error occurred"); } } } @@ -519,6 +519,9 @@ namespace Dalamud.Plugin.Internal LocalPlugin plugin; + if (!manifest.CheckSanity()) + throw new InvalidOperationException("Plugin manifest is not sane."); + if (isDev) { Log.Information($"Loading dev plugin {name}"); diff --git a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs index 21f0bd8d7..36e4d3c3c 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs @@ -1,5 +1,5 @@ using System.IO; - +using Dalamud.Utility; using Newtonsoft.Json; namespace Dalamud.Plugin.Internal.Types @@ -10,6 +10,24 @@ namespace Dalamud.Plugin.Internal.Types /// internal record LocalPluginManifest : PluginManifest { + /// + /// Check if this manifest is valid. + /// + /// Whether or not this manifest is valid. + public bool CheckSanity() + { + if (this.InternalName.IsNullOrEmpty()) + return false; + + if (this.Name.IsNullOrEmpty()) + return false; + + if (this.DalamudApiLevel != 0) + return false; + + return true; + } + /// /// Gets or sets a value indicating whether the plugin is disabled and should not be loaded. /// This value supercedes the ".disabled" file functionality and should not be included in the plugin master. diff --git a/Dalamud/Plugin/Internal/Types/PluginManifest.cs b/Dalamud/Plugin/Internal/Types/PluginManifest.cs index 5083d7e4c..9d28a1b5c 100644 --- a/Dalamud/Plugin/Internal/Types/PluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/PluginManifest.cs @@ -15,7 +15,7 @@ namespace Dalamud.Plugin.Internal.Types /// Gets the author/s of the plugin. /// [JsonProperty] - public string Author { get; init; } + public string? Author { get; init; } /// /// Gets or sets the public name of the plugin. diff --git a/Dalamud/Utility/StringExtensions.cs b/Dalamud/Utility/StringExtensions.cs index f452a2a0f..3aa9f70bd 100644 --- a/Dalamud/Utility/StringExtensions.cs +++ b/Dalamud/Utility/StringExtensions.cs @@ -18,13 +18,13 @@ namespace Dalamud.Utility /// /// The string to test. /// true if the value parameter is null or an empty string (""); otherwise, false. - public static bool IsNullOrEmpty(this string value) => string.IsNullOrEmpty(value); + public static bool IsNullOrEmpty(this string? value) => string.IsNullOrEmpty(value); /// /// Indicates whether a specified string is null, empty, or consists only of white-space characters. /// /// The string to test. /// true if the value parameter is null or an empty string (""), or if value consists exclusively of white-space characters. - public static bool IsNullOrWhitespace(this string value) => string.IsNullOrWhiteSpace(value); + public static bool IsNullOrWhitespace(this string? value) => string.IsNullOrWhiteSpace(value); } }