Author: markt Date: Tue Jun 20 21:06:57 2017 New Revision: 1799368 URL: http://svn.apache.org/viewvc?rev=1799368&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=61201 Ensure that the SCRIPT_NAME environment variable for CGI executables is populated in a consistent way regardless of how the CGI servlet is mapped to a request.
Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java tomcat/trunk/webapps/docs/cgi-howto.xml tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=1799368&r1=1799367&r2=1799368&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original) +++ tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Tue Jun 20 21:06:57 2017 @@ -799,13 +799,10 @@ public final class CGIServlet extends Ht path = currentLocation.getAbsolutePath(); name = currentLocation.getName(); - if (".".equals(contextPath)) { - scriptname = servletPath; + if (servletPath.startsWith(cginame)) { + scriptname = contextPath + cginame; } else { - scriptname = contextPath + servletPath; - } - if (!servletPath.equals(cginame)) { - scriptname = scriptname + cginame; + scriptname = contextPath + servletPath + cginame; } if (log.isDebugEnabled()) { Modified: tomcat/trunk/webapps/docs/cgi-howto.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/cgi-howto.xml?rev=1799368&r1=1799367&r2=1799368&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/cgi-howto.xml (original) +++ tomcat/trunk/webapps/docs/cgi-howto.xml Tue Jun 20 21:06:57 2017 @@ -121,6 +121,18 @@ the reading of stderr to complete before is <code>2000</code>.</li> </ul> +<p>The name and path of the CGI script to search for in the CGI search path +depends on how the Servlet has been mapped. If the <strong>pathInfo</strong> is +<code>null</code>, the <strong>servletPath</strong> will be used. If the +<strong>pathInfo</strong> is not <code>null</code> then the +<strong>servletPath</strong> is appended to the CGI search path and the +<strong>pathInfo</strong> is used.</p> + +<p>The search will start with the first path segment and expand one path segment +at a time until no path segments are left (resulting in a 404) or a matching +script is found in the CGI search path. Any remaining path segments will be +passed to the CGI executable in the <strong>PATH_INFO</strong> environment +variable.</p> </section> Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1799368&r1=1799367&r2=1799368&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Tue Jun 20 21:06:57 2017 @@ -131,6 +131,11 @@ provided by the application. This reverts a behavioural change in 9.0.0.M21 that caused problems for some clients. (markt) </fix> + <fix> + <bug>61201</bug>: Ensure that the <code>SCRIPT_NAME</code> environment + variable for CGI executables is populated in a consistent way regardless + of how the CGI servlet is mapped to a request. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org