fix: better sanity checking for bad plugin manifests

This commit is contained in:
goaaats 2021-12-18 12:27:57 +01:00
parent 8e5db448b2
commit 678cd0f130
No known key found for this signature in database
GPG key ID: F18F057873895461
5 changed files with 28 additions and 7 deletions

View file

@ -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}");

View file

@ -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
/// </summary>
internal record LocalPluginManifest : PluginManifest
{
/// <summary>
/// Check if this manifest is valid.
/// </summary>
/// <returns>Whether or not this manifest is valid.</returns>
public bool CheckSanity()
{
if (this.InternalName.IsNullOrEmpty())
return false;
if (this.Name.IsNullOrEmpty())
return false;
if (this.DalamudApiLevel != 0)
return false;
return true;
}
/// <summary>
/// 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.

View file

@ -15,7 +15,7 @@ namespace Dalamud.Plugin.Internal.Types
/// Gets the author/s of the plugin.
/// </summary>
[JsonProperty]
public string Author { get; init; }
public string? Author { get; init; }
/// <summary>
/// Gets or sets the public name of the plugin.