Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2011-11-22 23:18:32 +0000
committerShawn O. Pearce2011-11-22 23:19:02 +0000
commit9d311b333347d13ff2f9e0b7109e6b164a3643cc (patch)
treea2080486c295685c83970933b8a372fb2a54d84a /org.eclipse.jgit.http.server
parent3ee3811afb4f1077c3c991a589e37725585c7e06 (diff)
downloadjgit-9d311b333347d13ff2f9e0b7109e6b164a3643cc.tar.gz
jgit-9d311b333347d13ff2f9e0b7109e6b164a3643cc.tar.xz
jgit-9d311b333347d13ff2f9e0b7109e6b164a3643cc.zip
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
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java4
1 files 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 {

Back to the top