Skip to content

Commit

Permalink
SAK-29656 - Patch toolContextPath to match requestURL w.r.t tilde enc…
Browse files Browse the repository at this point in the history
…oding
  • Loading branch information
csev committed Jul 8, 2015
1 parent cf152b1 commit cc8889b
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,28 @@ public void forwardTool(ActiveTool tool, HttpServletRequest req,
HttpServletResponse res, Placement p, String skin, String toolContextPath,
String toolPathInfo) throws ToolException
{

// SAK-29656 - Make sure the request URL and toolContextPath treat tilde encoding the same way
//
// Since we cannot easily change what the request object already knows as its URL,
// we patch the toolContextPath to match the tilde encoding in the request URL.
//
// This is what we would see in Chrome and Firefox. Firefox fails with Wicket
// Chrome: forwardtool call http://localhost:8080/portal/site/~csev/tool/aaf64e38-00df-419a-b2ac-63cf2d7f99cf
// toolPathInfo null ctx /portal/site/~csev/tool/aaf64e38-00df-419a-b2ac-63cf2d7f99cf
// Firefox: http://localhost:8080/portal/site/%7ecsev/tool/aaf64e38-00df-419a-b2ac-63cf2d7f99cf/
// toolPathInfo null ctx /portal/site/~csev/tool/aaf64e38-00df-419a-b2ac-63cf2d7f99cf

String reqUrl = req.getRequestURL().toString();
if ( reqUrl.indexOf(toolContextPath) < 0 ) {
M_log.debug("Mismatch between request url " + reqUrl + " and toolContextPath " + toolContextPath);
if ( toolContextPath.indexOf("/~") > 0 && reqUrl.indexOf("/~") < 1 ) {
if ( reqUrl.indexOf("/%7e") > 0 ) {
toolContextPath = toolContextPath.replace("/~","/%7e");
} else {
toolContextPath = toolContextPath.replace("/~","/%7E");
}
}
}
M_log.debug("forwardtool call " + req.getRequestURL().toString() + " toolPathInfo " + toolPathInfo + " ctx " + toolContextPath);

// if there is a stored request state, and path, extract that from the
Expand Down

0 comments on commit cc8889b

Please sign in to comment.