Port SCRIPT_NAME fix
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Feb 2007 18:55:08 +0000 (18:55 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Feb 2007 18:55:08 +0000 (18:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@505743 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/servlets/CGIServlet.java
webapps/docs/changelog.xml

index c37d99a..4219c8a 100644 (file)
@@ -884,7 +884,7 @@ public final class CGIServlet extends HttpServlet {
             String path = null;
             String name = null;
             String scriptname = null;
-            String cginame = null;
+            String cginame = "";
 
             if ((webAppRootDir != null)
                 && (webAppRootDir.lastIndexOf(File.separator) ==
@@ -913,8 +913,9 @@ public final class CGIServlet extends HttpServlet {
                 if (debug >= 3) {
                     log("findCGI: currentLoc=" + currentLocation);
                 }
-                currentLocation = new File(currentLocation,
-                                           (String) dirWalker.nextElement());
+                String nextElement = (String) dirWalker.nextElement();
+                currentLocation = new File(currentLocation, nextElement);
+                cginame = cginame + "/" + nextElement;
             }
             if (!currentLocation.isFile()) {
                 return new String[] { null, null, null, null };
@@ -924,13 +925,14 @@ public final class CGIServlet extends HttpServlet {
                 }
                 path = currentLocation.getAbsolutePath();
                 name = currentLocation.getName();
-                cginame = (currentLocation.getParent() + File.separator).
-                        substring(webAppRootDir.length()) + name;
 
                 if (".".equals(contextPath)) {
-                    scriptname = servletPath + cginame;
+                    scriptname = servletPath;
                 } else {
-                    scriptname = contextPath + servletPath + cginame;
+                    scriptname = contextPath + servletPath;
+                }
+                if (!servletPath.equals(cginame)) {
+                    scriptname = scriptname + cginame;
                 }
             }
 
index 334ff62..e2037a5 100644 (file)
   </properties>
 
 <body>
+<section name="Tomcat 6.0.10 (remm)">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Fix formatting of CGI variable SCRIPT_NAME. (markt)
+      </fix>
+    </changelog>
+  </subsection>
+</section>
 <section name="Tomcat 6.0.9 (remm)">
   <subsection name="General">
     <changelog>