Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-22080] NPE if trying to install a plugin from the upda…
…te center and either the update source or the plugin contains a '.' in its name
  • Loading branch information
stephenc committed Mar 7, 2014
1 parent 21016fc commit f9b0f34
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions core/src/main/java/hudson/PluginManager.java
Expand Up @@ -684,13 +684,28 @@ public void doInstall(StaplerRequest req, StaplerResponse rsp) throws IOExceptio
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/");
Expand Down

0 comments on commit f9b0f34

Please sign in to comment.