提交 96fa4c4b 编写于 作者: S Seiji Sogabe

[FIXED JENKINS-11068] Port on HTTP Proxy Configure accepts characters except the digits

上级 e0f6a7a9
......@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Port on HTTP Proxy Configure accepts characters except the digits
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11068">issue 11068</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -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.
......
......@@ -50,5 +50,7 @@ Util.pastTime={0}
FilePath.TildaDoesntWork=''~'' is only supported in a Unix shell and nowhere else.
PluginManager.DisplayName=Plugin Manager
PluginManager.PortNotANumber=Port is not a number
PluginManager.PortNotInRange=Port does''t range from {0} to {1}
AboutJenkins.DisplayName=About Jenkins
AboutJenkins.Description=See the version and license information
......@@ -49,5 +49,7 @@ Util.pastTime={0} \u524d
FilePath.TildaDoesntWork=''~'' \u306f\u3001Unix\u306e\u30b7\u30a7\u30eb\u3067\u306e\u307f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002
PluginManager.DisplayName=\u30d7\u30e9\u30b0\u30a4\u30f3\u30de\u30cd\u30fc\u30b8\u30e3\u30fc
PluginManager.PortNotANumber=\u30dd\u30fc\u30c8\u756a\u53f7\u304c\u6570\u5b57\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002
PluginManager.PortNotInRange=\u30dd\u30fc\u30c8\u756a\u53f7\u304c{0}\u304b\u3089{1}\u307e\u3067\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002
AboutJenkins.DisplayName=Jenkins\u306b\u3064\u3044\u3066
AboutJenkins.Description=\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u30e9\u30a4\u30bb\u30f3\u30b9\u60c5\u5831\u3092\u8868\u793a\u3057\u307e\u3059\u3002
\ No newline at end of file
......@@ -41,7 +41,8 @@ THE SOFTWARE.
<f:textbox name="proxy.server" value="${app.proxy.name}" />
</f:entry>
<f:entry title="${%Port}" help="/help/update-center/proxy-port.html">
<f:textbox name="proxy.port" value="${app.proxy.port}" />
<f:textbox name="proxy.port" value="${app.proxy.port}"
checkUrl="'${rootURL}/pluginManager/checkProxyPort?value='+escape(this.value)" />
</f:entry>
</f:block>
<f:entry title="${%User name}" help="/help/update-center/proxy-username.html">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册