fix: correctly handle plugins with invalid Name,InternalName,AssemblyVersion

This commit is contained in:
goat 2023-06-14 20:46:00 +02:00
parent f1dfaa92c9
commit c1f10b21b3
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 28 additions and 3 deletions

View file

@ -2862,8 +2862,8 @@ internal class PluginInstallerWindow : Window, IDisposable
return true;
return hasSearchString && !(
manifest.Name.ToLowerInvariant().Contains(searchString) ||
manifest.InternalName.ToLowerInvariant().Contains(searchString) ||
(!manifest.Name.IsNullOrEmpty() && manifest.Name.ToLowerInvariant().Contains(searchString)) ||
(!manifest.InternalName.IsNullOrEmpty() && manifest.InternalName.ToLowerInvariant().Contains(searchString)) ||
(!manifest.Author.IsNullOrEmpty() && manifest.Author.Equals(this.searchText, StringComparison.InvariantCultureIgnoreCase)) ||
(!manifest.Punchline.IsNullOrEmpty() && manifest.Punchline.ToLowerInvariant().Contains(searchString)) ||
(manifest.Tags != null && manifest.Tags.Any(tag => tag.ToLowerInvariant().Contains(searchString))));

View file

@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Dalamud.Logging.Internal;
using Dalamud.Networking.Http;
using Dalamud.Utility;
using Newtonsoft.Json;
namespace Dalamud.Plugin.Internal.Types;
@ -145,7 +146,7 @@ internal class PluginRepository
return;
}
this.PluginMaster = pluginMaster.AsReadOnly();
this.PluginMaster = pluginMaster.Where(this.IsValidManifest).ToList().AsReadOnly();
Log.Information($"Successfully fetched repo: {this.PluginMasterUrl}");
this.State = PluginRepositoryState.Success;
@ -156,4 +157,28 @@ internal class PluginRepository
this.State = PluginRepositoryState.Fail;
}
}
private bool IsValidManifest(RemotePluginManifest manifest)
{
if (manifest.InternalName.IsNullOrWhitespace())
{
Log.Error("Repository at {RepoLink} has a plugin with an invalid InternalName.", this.PluginMasterUrl);
return false;
}
if (manifest.Name.IsNullOrWhitespace())
{
Log.Error("Plugin {PluginName} in {RepoLink} has an invalid Name.", manifest.InternalName, this.PluginMasterUrl);
return false;
}
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (manifest.AssemblyVersion == null)
{
Log.Error("Plugin {PluginName} in {RepoLink} has an invalid AssemblyVersion.", manifest.InternalName, this.PluginMasterUrl);
return false;
}
return true;
}
}