diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index 13f610c53..1d4ba4f83 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -669,29 +669,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 @@
+
+
+
+
+
+
+
+