github-advanced-security[bot] commented on code in PR #321:
URL: https://github.com/apache/roller/pull/321#discussion_r4651354576


##########
app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java:
##########
@@ -89,6 +93,44 @@
         return false;
     }
 
+    /**
+     * Sends a request whose session Roller has just ended, because its user's
+     * password or account changed, back to the page it asked for, or to the
+     * login page if it posted a form. Spring Security then asks for a login
+     * where one is needed, as it does for any visitor who is not logged in.
+     * Only the request the browser sent is redirected, not a forward.
+     *
+     * @return true when the request was redirected
+     */
+    static boolean redirectEndedSession(HttpServletRequest request, 
HttpServletResponse response)
+            throws IOException {
+        if (!RollerSession.isSessionEnded(request)
+                || request.getDispatcherType() != DispatcherType.REQUEST) {
+            return false;
+        }
+        String target;
+        if ("GET".equalsIgnoreCase(request.getMethod()) || 
"HEAD".equalsIgnoreCase(request.getMethod())) {
+            target = request.getContextPath() + request.getServletPath()
+                    + (request.getPathInfo() != null ? request.getPathInfo() : 
"")
+                    + (request.getQueryString() != null ? "?" + 
request.getQueryString() : "");
+            if (!isLocalPath(target)) {
+                target = request.getContextPath() + "/";
+            }
+        } else {
+            target = request.getContextPath() + "/roller-ui/login.rol";
+        }
+        response.sendRedirect(target);

Review Comment:
   ## CodeQL / URL redirection from remote source
   
   Untrusted URL redirection depends on a [user-provided value](1).
   Untrusted URL redirection depends on a [user-provided value](2).
   
   [Show more 
details](https://github.com/apache/roller/security/code-scanning/160)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to