merge with branch issue-436

This commit is contained in:
Sebastian Sdorra
2013-08-27 20:37:10 +02:00

View File

@@ -45,8 +45,8 @@ import org.tmatesoft.svn.core.internal.server.dav.DAVConfig;
import org.tmatesoft.svn.core.internal.server.dav.DAVServlet;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryRequestListenerUtil;
import sonia.scm.repository.RepositoryProvider;
import sonia.scm.repository.RepositoryRequestListenerUtil;
import sonia.scm.repository.SvnRepositoryHandler;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.HttpUtil;
@@ -68,6 +68,9 @@ import javax.servlet.http.HttpServletResponse;
public class SvnDAVServlet extends DAVServlet
{
/** Field description */
private static final String HEADER_CONTEXTPATH = "X-Forwarded-Ctx";
/** Field description */
private static final long serialVersionUID = -1462257085465785945L;
@@ -86,8 +89,7 @@ public class SvnDAVServlet extends DAVServlet
* @param repositoryRequestListenerUtil
*/
@Inject
public SvnDAVServlet(
SvnRepositoryHandler handler,
public SvnDAVServlet(SvnRepositoryHandler handler,
RepositoryProvider repositoryProvider,
RepositoryRequestListenerUtil repositoryRequestListenerUtil)
{
@@ -177,6 +179,25 @@ public class SvnDAVServlet extends DAVServlet
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getContextPath()
{
String header = getHeader(HEADER_CONTEXTPATH);
if ((header == null) ||!isValidContextPath(header))
{
header = super.getContextPath();
}
return header;
}
/**
* Method description
*
@@ -230,6 +251,32 @@ public class SvnDAVServlet extends DAVServlet
return servletPath;
}
/**
* Method description
*
*
* @param ctx
*
* @return
*/
private boolean isValidContextPath(String ctx)
{
int length = ctx.length();
boolean result = (length == 0)
|| ((length > 1)
&& ctx.startsWith(HttpUtil.SEPARATOR_PATH));
if (!result)
{
logger.warn(
"header {} contains a non valid context path, fallback to default",
HEADER_CONTEXTPATH);
}
return result;
}
//~--- fields -------------------------------------------------------------
/** Field description */