]> source.dussan.org Git - jgit.git/commitdiff
Strip leading slashes in RepositoryFilter 66/4666/1
authorShawn O. Pearce <spearce@spearce.org>
Tue, 22 Nov 2011 23:18:32 +0000 (15:18 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 22 Nov 2011 23:19:02 +0000 (15:19 -0800)
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

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

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