Skip to content

Commit

Permalink
SAK-20286 applied patch from Roeland
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/jsf/trunk@90571 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
axxter99 committed Mar 25, 2011
1 parent 8aeaa74 commit 5e839f2
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -132,9 +133,25 @@ public String getResourceURL(FacesContext arg0, String arg1)
return m_wrapped.getResourceURL(arg0, arg1);
}

public void renderView(FacesContext arg0, UIViewRoot arg1) throws IOException, FacesException
{
m_wrapped.renderView(arg0, arg1);
public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException {
// SAK-20286 start
// Get the request
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
String requestURI = req.getRequestURI();
// Make the attribute name unique to the request
String attrName = "sakai.jsf.tool.URL.loopDetect.viewId-" + requestURI;
// Try to fetch the attribute
Object attribute = req.getAttribute(attrName);
// If the attribute is null, this is the first request for this view
if (attribute == null) {
req.setAttribute(attrName, "true");
} else if ("true".equals(attribute)) { // A looping request is detected.
HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse();
// Send a 404
res.sendError(404, "File not found: " + requestURI);
}
// SAK-20286 end
m_wrapped.renderView(context, root);
}

public UIViewRoot restoreView(FacesContext arg0, String arg1)
Expand Down

0 comments on commit 5e839f2

Please sign in to comment.