Fix possible exception when extracting zip file

This commit is contained in:
Jack251970 2025-06-29 16:24:21 +08:00
parent 104b4b2680
commit 3e9e91d71c
3 changed files with 30 additions and 3 deletions

View file

@ -46,6 +46,9 @@
<system:String x:Key="plugin_pluginsmanager_update_all_success_no_restart">{0} plugins successfully updated. Please restart Flow.</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_modified_error">Plugin {0} has already been modified. Please restart Flow before making any further changes.</system:String>
<system:String x:Key="plugin_pluginsmanager_invalid_zip_title">Invalid zip installer file</system:String>
<system:String x:Key="plugin_pluginsmanager_invalid_zip_subtitle">Please check if there is plugin.json in {0}</system:String>
<!-- Plugin Infos -->
<system:String x:Key="plugin_pluginsmanager_plugin_name">Plugins Manager</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_description">Management of installing, uninstalling or updating Flow Launcher plugins</system:String>

View file

@ -242,6 +242,18 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (FilesFolders.IsZipFilePath(search, checkFileExists: true))
{
pluginFromLocalPath = Utilities.GetPluginInfoFromZip(search);
if (pluginFromLocalPath == null) return new List<Result>
{
new()
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_title"),
SubTitle = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_subtitle"),
search),
IcoPath = icoPath
}
};
pluginFromLocalPath.LocalInstallPath = search;
updateFromLocalPath = true;
}
@ -559,6 +571,20 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
var plugin = Utilities.GetPluginInfoFromZip(localPath);
if (plugin == null)
{
return new List<Result>
{
new()
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_title"),
SubTitle = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_subtitle"),
localPath),
IcoPath = icoPath
}
};
}
plugin.LocalInstallPath = localPath;
return new List<Result>

View file

@ -65,9 +65,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
using (ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(filePath))
{
var pluginJsonPath = archive.Entries.FirstOrDefault(x => x.Name == "plugin.json").ToString();
ZipArchiveEntry pluginJsonEntry = archive.GetEntry(pluginJsonPath);
var pluginJsonEntry = archive.Entries.FirstOrDefault(x => x.Name == "plugin.json");
if (pluginJsonEntry != null)
{
using Stream stream = pluginJsonEntry.Open();