<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div class="" style=""><span style="background-color: transparent;">Hello list and especially keepers and curators of the opencms source code, this question is mostly for you but it could be for anyone whose worked extensively with OpenCmsServlet.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span style="background-color: transparent;"><br></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span style="background-color: transparent;">I inherited an OpenCms project
a while back where the previous developer had riddled the Opencms source code with a bunch of mostly unnecessary customization that made it impossible to upgrade to newer versions. It was stuck at 7.0.1</span><br></div><div class="" style=""><br class="" style=""></div><div class="" style="">As I've been settling a ton of technical debt, I've removed all but one src code modification and been upgrading to newer versions of OpenCms but I've carried that one forward in org.opencms.main.OpenCmsServlet that I think could be useful.</div><div class="" style=""><br class="" style=""></div><div class="" style="">in 8.5.1 the invokeHandler goes from</div><div class="" style=""><br class="" style=""></div><div class="" style=""> protected void invokeHandler(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {</div><div class="" style=""><br class="" style=""></div><div class="" style="">
String name = OpenCmsCore.getInstance().getPathInfo(req).substring(HANDLE_PATH.length());</div><div class="" style=""> I_CmsRequestHandler handler = OpenCmsCore.getInstance().getRequestHandler(name);</div><div class="" style=""> if (handler != null) {</div><div class="" style=""> handler.handle(req, res, name);</div><div class="" style=""> } else {</div><div class="" style=""> openErrorHandler(req, res, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);</div><div class="" style=""> }</div><div class="" style=""> }</div><div class="" style=""><br class="" style=""></div><div class="" style=""> protected void invokeHandler(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {</div><div class="" style=""><br
class="" style=""></div><div class="" style=""> String name = OpenCmsCore.getInstance().getPathInfo(req).substring(HANDLE_PATH.length());</div><div class="" style=""><span style="font-weight: bold;"> int iIndex = name.indexOf( "/" );</span></div><div class="" style=""><span style="font-weight: bold;"> if ( iIndex >= 0 ) {</span></div><div class="" style=""><span style="font-weight: bold;"> <span class="" style="white-space:pre"> </span>name = name.substring( 0, iIndex );</span></div><div class="" style=""><span style="font-weight: bold;"> }</span></div><div class="" style=""> I_CmsRequestHandler handler = OpenCmsCore.getInstance().getRequestHandler(name);</div><div class="" style=""> if (handler != null) {</div><div class="" style="">
handler.handle(req, res, name);</div><div class="" style=""> } else {</div><div class="" style=""> openErrorHandler(req, res, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);</div><div class="" style=""> }</div><div class="" style=""> }</div><div class="" style=""><br class="" style=""></div><div class="" style="">essentially it allows for the path to the servlet to still find a match for the handler even if there's some random runtime generated stuff in it that the handler (that you design) will correctly interpret</div><div class="" style=""><br class="" style=""></div><div class="" style="">In my case it's a captcha with the random string generating an image captcha on the fly based upon the value passed to it (/handleCaptcha/148af064124/captcha.jpg)</div><div class="" style=""><br class="" style=""></div><div class="" style="">I
thought to rip this whole thing out and use the official captcha code, but it works fine as long as I keep the customization.</div><div class="" style=""><br class="" style=""></div><div class="" style="">Is there some better way for me to do this w/o the customization? (for example can the handler be a regex the way you could specify for a servlet in the web.xml?)</div><div class="" style=""><br class="" style=""></div><div class="" style="">Does this seem insecure to you in any way? </div><div class="" style=""><br class="" style=""></div><div class="" style="">Is this something that jibes with the purpose/usage of the OpenCmsServlet that you think might be useful to include in upgrades?</div><div class="" style=""><br class="" style=""></div></div></body></html>