Browse Source

Strip leading slashes in RepositoryFilter

If removing the leading slash results in an empty string, return
with an HTTP 404 error before trying to use the RepositoryResolver.
Moving this into a loop ahead of the length check ensures there is
no empty string passed into the resolver.

Change-Id: I80e5b7cf25ae9f2164b5c396a29773e5c7d7286e
stable-1.2
Shawn O. Pearce 13 years ago
parent
commit
9d311b3333
  1. 4
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java

4
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java

@ -122,12 +122,12 @@ public class RepositoryFilter implements Filter {
final HttpServletRequest req = (HttpServletRequest) request; final HttpServletRequest req = (HttpServletRequest) request;
String name = req.getPathInfo(); String name = req.getPathInfo();
while (name != null && 0 < name.length() && name.charAt(0) == '/')
name = name.substring(1);
if (name == null || name.length() == 0) { if (name == null || name.length() == 0) {
((HttpServletResponse) rsp).sendError(SC_NOT_FOUND); ((HttpServletResponse) rsp).sendError(SC_NOT_FOUND);
return; return;
} }
if (name.startsWith("/"))
name = name.substring(1);
final Repository db; final Repository db;
try { try {

Loading…
Cancel
Save