mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 15:45:52 +00:00
[FIXED JENKINS-11068] Port on HTTP Proxy Configure accepts characters except the digits
This commit is contained in:
1 parent
e0f6a7a9b4
commit
96fa4c4bab
5 files changed
+29
-5
No files matched your search
@@ -37,6 +37,7 @@ import hudson.model.UpdateCenter;
|
||||
import hudson.model.UpdateSite;
|
||||
import hudson.util.CyclicGraphDetector;
|
||||
import hudson.util.CyclicGraphDetector.CycleDetectedException;
|
||||
import hudson.util.FormValidation;
|
||||
import hudson.util.PersistedList;
|
||||
import hudson.util.Service;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
@@ -565,15 +566,31 @@ public abstract class PluginManager extends AbstractModelObject {
|
||||
hudson.proxy = null;
|
||||
ProxyConfiguration.getXmlFile().delete();
|
||||
} else try {
|
||||
hudson.proxy = new ProxyConfiguration(server,Integer.parseInt(Util.fixNull(port)),
|
||||
int proxyPort = Integer.parseInt(Util.fixNull(port));
|
||||
if (proxyPort < 0 || proxyPort > 65535) {
|
||||
throw new Failure(Messages.PluginManager_PortNotInRange(0, 65535));
|
||||
}
|
||||
hudson.proxy = new ProxyConfiguration(server, proxyPort,
|
||||
Util.fixEmptyAndTrim(userName),Util.fixEmptyAndTrim(password));
|
||||
hudson.proxy.save();
|
||||
} catch (NumberFormatException nfe) {
|
||||
return HttpResponses.error(StaplerResponse.SC_BAD_REQUEST,
|
||||
new IllegalArgumentException("Invalid proxy port: " + port, nfe));
|
||||
throw new Failure(Messages.PluginManager_PortNotANumber());
|
||||
}
|
||||
return new HttpRedirect("advanced");
|
||||
}
|
||||
|
||||
public FormValidation doCheckProxyPort(@QueryParameter String value) {
|
||||
int port;
|
||||
try {
|
||||
port = Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return FormValidation.error(Messages.PluginManager_PortNotANumber());
|
||||
}
|
||||
if (port < 0 || port > 65535) {
|
||||
return FormValidation.error(Messages.PluginManager_PortNotInRange(0, 65535));
|
||||
}
|
||||
return FormValidation.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a plugin.
|
||||
|
||||
Reference in new issue
Block a user