From 2b927737c9387a3c9cf896a68ba2fc9f65721d8e Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 20 Apr 2022 10:00:50 +0100 Subject: [PATCH] Ignore invalid jars inside of the updates folder (Fixes #7751) This really needs a deeper look here, the way updates are handled is fairly immature, but, this wasn't ever intended to be a large scale thing Ideally, imho, we'd collect the list of update files into some form of Map, that way we just have a reference of Name > File refs, and can filter out cases where there are two versions of a plugin in there and warn expectidely, but, that creates some complications, you would need to fall back to a dir scan in the case of a plugin calling loadPlugin, but, it would at least give us more defined behavior, as well as improve performance here vs repeatidely trying to deserialise the plugin.yml defs for every file in there on every load --- patches/api/Update-Folder-Uses-Plugin-Name.patch | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/patches/api/Update-Folder-Uses-Plugin-Name.patch b/patches/api/Update-Folder-Uses-Plugin-Name.patch index 04d7277552..bd0fcf01f1 100644 --- a/patches/api/Update-Folder-Uses-Plugin-Name.patch +++ b/patches/api/Update-Folder-Uses-Plugin-Name.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (updateDirectory == null || !updateDirectory.isDirectory()) { - return; + return file; - } ++ } + PluginLoader pluginLoader = getPluginLoader(file); + try { + String pluginName = pluginLoader.getPluginDescription(file).getName(); @@ -40,7 +40,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!updateFile.isFile()) continue; + PluginLoader updatePluginLoader = getPluginLoader(updateFile); + if (updatePluginLoader == null) continue; -+ String updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName(); ++ String updatePluginName; ++ try { ++ updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName(); ++ // We failed to load this data for some reason, so, we'll skip over this ++ } catch (InvalidDescriptionException ex) { ++ continue; ++ } + if (!pluginName.equals(updatePluginName)) continue; + if (!FileUtil.copy(updateFile, file)) continue; + File newName = new File(file.getParentFile(), updateFile.getName()); @@ -51,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + catch (InvalidDescriptionException e) { + throw new InvalidPluginException(e); -+ } + } + return file; + }