Skip to content

Commit 3e9e91d

Browse files
committed
Fix possible exception when extracting zip file
1 parent 104b4b2 commit 3e9e91d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
<system:String x:Key="plugin_pluginsmanager_update_all_success_no_restart">{0} plugins successfully updated. Please restart Flow.</system:String>
4747
<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>
4848

49+
<system:String x:Key="plugin_pluginsmanager_invalid_zip_title">Invalid zip installer file</system:String>
50+
<system:String x:Key="plugin_pluginsmanager_invalid_zip_subtitle">Please check if there is plugin.json in {0}</system:String>
51+
4952
<!-- Plugin Infos -->
5053
<system:String x:Key="plugin_pluginsmanager_plugin_name">Plugins Manager</system:String>
5154
<system:String x:Key="plugin_pluginsmanager_plugin_description">Management of installing, uninstalling or updating Flow Launcher plugins</system:String>

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ internal async ValueTask<List<Result>> RequestUpdateAsync(string search, Cancell
242242
if (FilesFolders.IsZipFilePath(search, checkFileExists: true))
243243
{
244244
pluginFromLocalPath = Utilities.GetPluginInfoFromZip(search);
245+
246+
if (pluginFromLocalPath == null) return new List<Result>
247+
{
248+
new()
249+
{
250+
Title = Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_title"),
251+
SubTitle = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_subtitle"),
252+
search),
253+
IcoPath = icoPath
254+
}
255+
};
256+
245257
pluginFromLocalPath.LocalInstallPath = search;
246258
updateFromLocalPath = true;
247259
}
@@ -559,6 +571,20 @@ internal List<Result> InstallFromLocalPath(string localPath)
559571
{
560572
var plugin = Utilities.GetPluginInfoFromZip(localPath);
561573

574+
if (plugin == null)
575+
{
576+
return new List<Result>
577+
{
578+
new()
579+
{
580+
Title = Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_title"),
581+
SubTitle = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_invalid_zip_subtitle"),
582+
localPath),
583+
IcoPath = icoPath
584+
}
585+
};
586+
}
587+
562588
plugin.LocalInstallPath = localPath;
563589

564590
return new List<Result>

Plugins/Flow.Launcher.Plugin.PluginsManager/Utilities.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ internal static UserPlugin GetPluginInfoFromZip(string filePath)
6565

6666
using (ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(filePath))
6767
{
68-
var pluginJsonPath = archive.Entries.FirstOrDefault(x => x.Name == "plugin.json").ToString();
69-
ZipArchiveEntry pluginJsonEntry = archive.GetEntry(pluginJsonPath);
70-
68+
var pluginJsonEntry = archive.Entries.FirstOrDefault(x => x.Name == "plugin.json");
7169
if (pluginJsonEntry != null)
7270
{
7371
using Stream stream = pluginJsonEntry.Open();

0 commit comments

Comments
 (0)