Преглед изворни кода

Improve HTTP redirect URL encoding.

Ben Alex пре 21 година
родитељ
комит
0cbea9b452

+ 2 - 1
core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpEntryPoint.java

@@ -117,6 +117,7 @@ public class RetryWithHttpEntryPoint implements InitializingBean,
             logger.debug("Redirecting to: " + redirectUrl);
         }
 
-        ((HttpServletResponse) response).sendRedirect(redirectUrl);
+        ((HttpServletResponse) response).sendRedirect(((HttpServletResponse) response)
+            .encodeRedirectURL(redirectUrl));
     }
 }

+ 2 - 1
core/src/main/java/org/acegisecurity/securechannel/RetryWithHttpsEntryPoint.java

@@ -117,6 +117,7 @@ public class RetryWithHttpsEntryPoint implements InitializingBean,
             logger.debug("Redirecting to: " + redirectUrl);
         }
 
-        ((HttpServletResponse) response).sendRedirect(redirectUrl);
+        ((HttpServletResponse) response).sendRedirect(((HttpServletResponse) response)
+            .encodeRedirectURL(redirectUrl));
     }
 }

+ 3 - 3
core/src/main/java/org/acegisecurity/ui/AbstractProcessingFilter.java

@@ -224,8 +224,8 @@ public abstract class AbstractProcessingFilter implements Filter,
                     failed);
                 httpRequest.getSession().setAttribute(HttpSessionIntegrationFilter.ACEGI_SECURITY_AUTHENTICATION_KEY,
                     null);
-                httpResponse.sendRedirect(httpRequest.getContextPath()
-                    + authenticationFailureUrl);
+                httpResponse.sendRedirect(httpResponse.encodeRedirectURL(httpRequest
+                        .getContextPath() + authenticationFailureUrl));
 
                 return;
             }
@@ -252,7 +252,7 @@ public abstract class AbstractProcessingFilter implements Filter,
                     + targetUrl);
             }
 
-            httpResponse.sendRedirect(targetUrl);
+            httpResponse.sendRedirect(httpResponse.encodeRedirectURL(targetUrl));
 
             return;
         }

+ 2 - 1
core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterEntryPoint.java

@@ -176,6 +176,7 @@ public class AuthenticationProcessingFilterEntryPoint
             logger.debug("Redirecting to: " + redirectUrl);
         }
 
-        ((HttpServletResponse) response).sendRedirect(redirectUrl);
+        ((HttpServletResponse) response).sendRedirect(((HttpServletResponse) response)
+            .encodeRedirectURL(redirectUrl));
     }
 }

+ 1 - 1
core/src/test/java/org/acegisecurity/MockHttpServletResponse.java

@@ -146,7 +146,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
     }
 
     public String encodeRedirectURL(String arg0) {
-        throw new UnsupportedOperationException("mock method not implemented");
+        return arg0;
     }
 
     public String encodeRedirectUrl(String arg0) {