From 9d311b333347d13ff2f9e0b7109e6b164a3643cc Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 22 Nov 2011 15:18:32 -0800 Subject: [PATCH] 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 --- .../src/org/eclipse/jgit/http/server/RepositoryFilter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java index 1462593858..d1bd9024e9 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java +++ b/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; 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 { -- 2.39.5