mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
fix: better sanity checking for bad plugin manifests
This commit is contained in:
parent
8e5db448b2
commit
678cd0f130
5 changed files with 28 additions and 7 deletions
|
|
@ -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}");
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue