aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2011-10-12 10:55:00 (EDT)
committerSimone Bordet2011-11-04 10:56:18 (EDT)
commit3d0300e60df9df6b8c8fd158b5dc80533bf58c62 (patch)
treee19387018537c55a2d7c35fbc3b33af3da689695
parentb9f45e9426d16c6a075e96df127775d37bd6d331 (diff)
downloadorg.eclipse.jetty.project-3d0300e60df9df6b8c8fd158b5dc80533bf58c62.zip
org.eclipse.jetty.project-3d0300e60df9df6b8c8fd158b5dc80533bf58c62.tar.gz
org.eclipse.jetty.project-3d0300e60df9df6b8c8fd158b5dc80533bf58c62.tar.bz2
359031: CGI servlet changed to allow relative paths to webapp
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java
index 04dbf62..d8757d8 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java
@@ -35,7 +35,8 @@ import org.eclipse.jetty.util.log.Logger;
/**
* CGI Servlet.
*
- * The cgi bin directory can be set with the "cgibinResourceBase" init parameter or it will default to the resource base of the context.
+ * The cgi bin directory can be set with the "cgibinResourceBase" init parameter or it will default to the resource base of the context. If the
+ * "cgibinResourceBaseIsRelative" init parameter is set the resource base is relative to the webapp. For example "WEB-INF/cgi" would work.
*
* The "commandPrefix" init parameter may be used to set a prefix to all commands passed to exec. This can be used on systems that need assistance to execute a
* particular file type. For example on windows this can be set to "perl" so that perl scripts are executed.
@@ -57,6 +58,7 @@ public class CGI extends HttpServlet
private String _cmdPrefix;
private EnvList _env;
private boolean _ignoreExitState;
+ private boolean _relative;
/* ------------------------------------------------------------ */
@Override
@@ -64,6 +66,7 @@ public class CGI extends HttpServlet
{
_env = new EnvList();
_cmdPrefix = getInitParameter("commandPrefix");
+ _relative = Boolean.parseBoolean(getInitParameter("cgibinResourceBaseIsRelative"));
String tmp = getInitParameter("cgibinResourceBase");
if (tmp == null)
@@ -72,6 +75,10 @@ public class CGI extends HttpServlet
if (tmp == null)
tmp = getServletContext().getRealPath("/");
}
+ else if (_relative)
+ {
+ tmp = getServletContext().getRealPath(tmp);
+ }
if (tmp == null)
{
@@ -142,8 +149,7 @@ public class CGI extends HttpServlet
return;
}
- String pathInContext = StringUtil.nonNull(req.getServletPath()) + StringUtil.nonNull(req.getPathInfo());
-
+ String pathInContext = (_relative?"":StringUtil.nonNull(req.getServletPath())) + StringUtil.nonNull(req.getPathInfo());
if (LOG.isDebugEnabled())
{
LOG.debug("CGI: ContextPath : " + req.getContextPath());