Fixed: "entity/list" request is not handled well
(OFBIZ-11593) The "entity/list" request has been put in with OFBIZ-11007. It's used to call the entitymaint view and so is a demo/didactic duplicate of entitymaint request. It's only used in FindGeneric screen (look for WebtoolsBackToEntityList label). It's problematic because since the CSRF token defense was put in you can no longer filter the entities from the entities list screen, even when the default NoCsrfDefenseStrategy is used. It works if you use the entitymaint request instead. Anyway, 2020-01-19 I proposed in OFBIZ-11306 a solution for such cases. It was not used because 2020-02-14 I thought it was no longer needed, but it's necessary for this case, and maybe others not already detected. Here it's implementation (only trunk)
This commit is contained in:
@@ -43,6 +43,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.cxf.jaxrs.model.URITemplate;
|
||||
import org.apache.ofbiz.base.location.FlexibleLocation;
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
@@ -146,7 +147,7 @@ public class RequestHandler {
|
||||
String overrideViewUri = getOverrideViewUri(path);
|
||||
if (requestMapMap.containsKey(requestUri)
|
||||
// Ensure that overridden view exists.
|
||||
&& (overrideViewUri == null || viewMapMap.containsKey(overrideViewUri)
|
||||
&& (overrideViewUri == null || viewMapMap.containsKey(overrideViewUri)
|
||||
|| ("SOAPService".equals(requestUri) && "wsdl".equalsIgnoreCase(req.getQueryString())))){
|
||||
rmaps = requestMapMap.get(requestUri);
|
||||
req.setAttribute("overriddenView", overrideViewUri);
|
||||
@@ -495,7 +496,7 @@ public class RequestHandler {
|
||||
|
||||
if (requestMap.event.metrics != null) {
|
||||
requestMap.event.metrics.recordServiceRate(1, System.currentTimeMillis() - startTime);
|
||||
}
|
||||
}
|
||||
|
||||
// save the server hit for the request event
|
||||
if (this.trackStats(request)) {
|
||||
@@ -832,7 +833,11 @@ public class RequestHandler {
|
||||
if (pathInfo.get(0).indexOf('?') > -1) {
|
||||
return pathInfo.get(0).substring(0, pathInfo.get(0).indexOf('?'));
|
||||
} else {
|
||||
return pathInfo.get(0);
|
||||
if (1 < StringUtils.countMatches(path, "/")) {
|
||||
return pathInfo.get(0) + "/" + pathInfo.get(1);
|
||||
} else {
|
||||
return pathInfo.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +870,7 @@ public class RequestHandler {
|
||||
statusCode = Integer.valueOf(statusCodeString);
|
||||
} catch (NumberFormatException e) {
|
||||
statusCode = 303;
|
||||
}
|
||||
}
|
||||
while (attributeNameEnum.hasMoreElements()) {
|
||||
String name = attributeNameEnum.nextElement();
|
||||
Object obj = req.getAttribute(name);
|
||||
@@ -885,7 +890,7 @@ public class RequestHandler {
|
||||
}
|
||||
|
||||
// send the redirect
|
||||
try {
|
||||
try {
|
||||
resp.setStatus(statusCode);
|
||||
resp.setHeader("Location", url);
|
||||
resp.setHeader("Connection", "close");
|
||||
@@ -1219,7 +1224,7 @@ public class RequestHandler {
|
||||
Collection<ConfigXMLReader.Event> get() throws WebAppConfigurationException;
|
||||
}
|
||||
|
||||
private void runEvents(HttpServletRequest req, HttpServletResponse res,
|
||||
private void runEvents(HttpServletRequest req, HttpServletResponse res,
|
||||
EventCollectionProducer prod, String trigger) {
|
||||
try {
|
||||
for (ConfigXMLReader.Event event: prod.get()) {
|
||||
@@ -1312,7 +1317,7 @@ public class RequestHandler {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
boolean showSessionIdInLog = EntityUtilProperties.propertyValueEqualsIgnoreCase("requestHandler", "show-sessionId-in-log", "Y", delegator);
|
||||
if (showSessionIdInLog) {
|
||||
return " sessionId=" + UtilHttp.getSessionId(request);
|
||||
return " sessionId=" + UtilHttp.getSessionId(request);
|
||||
}
|
||||
return " Hidden sessionId by default.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user