diff --git a/changelog.html b/changelog.html index ef84abe2b5..fa3e9f9044 100644 --- a/changelog.html +++ b/changelog.html @@ -55,7 +55,9 @@ Upcoming changes
diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 156a38d43e..f79470ab13 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -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. diff --git a/core/src/main/resources/hudson/Messages.properties b/core/src/main/resources/hudson/Messages.properties index c4edc3a6d9..fb82bc8266 100644 --- a/core/src/main/resources/hudson/Messages.properties +++ b/core/src/main/resources/hudson/Messages.properties @@ -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 diff --git a/core/src/main/resources/hudson/Messages_ja.properties b/core/src/main/resources/hudson/Messages_ja.properties index 30e521ba4e..87671bcdec 100644 --- a/core/src/main/resources/hudson/Messages_ja.properties +++ b/core/src/main/resources/hudson/Messages_ja.properties @@ -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 diff --git a/core/src/main/resources/hudson/PluginManager/advanced.jelly b/core/src/main/resources/hudson/PluginManager/advanced.jelly index 904d3d6c1f..ceb464948f 100644 --- a/core/src/main/resources/hudson/PluginManager/advanced.jelly +++ b/core/src/main/resources/hudson/PluginManager/advanced.jelly @@ -41,7 +41,8 @@ THE SOFTWARE.