From f9b0f348d0ff674fe058eb1aa4d609c6e3e962e5 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Fri, 7 Mar 2014 15:26:06 +0000 Subject: [PATCH] [FIXED JENKINS-22080] NPE if trying to install a plugin from the update center and either the update source or the plugin contains a '.' in its name --- core/src/main/java/hudson/PluginManager.java | 27 +++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index ace1d44d41..ccf17cf176 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -684,13 +684,28 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas String n = en.nextElement(); if(n.startsWith("plugin.")) { n = n.substring(7); - if (n.indexOf(".") > 0) { - String[] pluginInfo = n.split("\\."); - UpdateSite.Plugin p = Jenkins.getInstance().getUpdateCenter().getById(pluginInfo[1]).getPlugin(pluginInfo[0]); - if(p==null) - throw new Failure("No such plugin: "+n); - p.deploy(dynamicLoad); + // JENKINS-22080 plugin names can contain '.' as could (according to rumour) update sites + int index = n.indexOf('.'); + UpdateSite.Plugin p = null; + while (index != -1) { + if (index + 1 >= n.length()) { + break; + } + String pluginName = n.substring(0, index); + String siteName = n.substring(index + 1); + UpdateSite updateSite = Jenkins.getInstance().getUpdateCenter().getById(siteName); + if (siteName != null) { + if (p != null) { + throw new Failure("Ambiguous plugin: " + n); + } + p = updateSite.getPlugin(pluginName); + } + index = n.indexOf('.', index + 1); } + if (p == null) { + throw new Failure("No such plugin: " + n); + } + p.deploy(dynamicLoad); } } rsp.sendRedirect("../updateCenter/");