diff --git a/WHATSNEW b/WHATSNEW index ff97c1486..b34197e39 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -1,6 +1,14 @@ Changes from Ant 1.10.4 TO Ant 1.10.5 ===================================== +Fixed bugs: +----------- + + * Fixes a regression in the "get" task where redirects + from a HTTP resource to a HTTPS resource started throwing + an exception. + Bugzilla Report 62499 + Changes from Ant 1.10.3 TO Ant 1.10.4 ===================================== diff --git a/manual/credits.html b/manual/credits.html index 77327acfb..5c12b4758 100644 --- a/manual/credits.html +++ b/manual/credits.html @@ -19,7 +19,7 @@ -Apache Ant User Manual—Credits +Apache Ant User Manual - Credits diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index b44a0118f..6d3503d7e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -693,29 +693,34 @@ public class Get extends Task { private boolean redirectionAllowed(final URL aSource, final URL aDest) { - if (aSource.getProtocol().equals(aDest.getProtocol()) - && (HTTP.equals(aSource.getProtocol()) || HTTPS.equals(aDest.getProtocol()))) { - redirections++; - if (redirections > REDIRECT_LIMIT) { - final String message = "More than " + REDIRECT_LIMIT - + " times redirected, giving up"; - if (ignoreErrors) { - log(message, logLevel); - return false; - } + if (!(aSource.getProtocol().equals(aDest.getProtocol()) || (HTTP + .equals(aSource.getProtocol()) && HTTPS.equals(aDest + .getProtocol())))) { + final String message = "Redirection detected from " + + aSource.getProtocol() + " to " + aDest.getProtocol() + + ". Protocol switch unsafe, not allowed."; + if (ignoreErrors) { + log(message, logLevel); + return false; + } else { throw new BuildException(message); } - return true; } - final String message = "Redirection detected from " - + aSource.getProtocol() + " to " + aDest.getProtocol() - + ". Protocol switch unsafe, not allowed."; - if (ignoreErrors) { - log(message, logLevel); - return false; + redirections++; + if (redirections > REDIRECT_LIMIT) { + final String message = "More than " + REDIRECT_LIMIT + + " times redirected, giving up"; + if (ignoreErrors) { + log(message, logLevel); + return false; + } else { + throw new BuildException(message); + } } - throw new BuildException(message); + + + return true; } private URLConnection openConnection(final URL aSource) throws IOException { diff --git a/src/tests/antunit/taskdefs/get-test.xml b/src/tests/antunit/taskdefs/get-test.xml index a8ca6a911..b4543f579 100644 --- a/src/tests/antunit/taskdefs/get-test.xml +++ b/src/tests/antunit/taskdefs/get-test.xml @@ -122,4 +122,13 @@ + + + + + + + +