diff options
author | paladox <paladox@users.noreply.github.com> | 2015-11-23 17:58:38 +0000 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2015-11-23 13:32:00 -0500 |
commit | 2b1e02997f12e2cf12088d2e9f6eef107e1ce8f5 (patch) | |
tree | dbb84a36e69b789f2812db2bd1d2f9a0be67e79b /src | |
parent | 1fe804a2862c8121e87f44b48d2058889734494b (diff) | |
download | gitblit-2b1e02997f12e2cf12088d2e9f6eef107e1ce8f5.tar.gz gitblit-2b1e02997f12e2cf12088d2e9f6eef107e1ce8f5.zip |
Match longest repository path towards the shortest pr-950
This was originally from https://github.com/gitblit/gitblit/pull/950 but seems to have been reverted when develop branch was merged with master.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/servlet/RawServlet.java | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index 1d2724bc..e11bc505 100644 --- a/src/main/java/com/gitblit/servlet/RawServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -166,23 +166,14 @@ public class RawServlet extends HttpServlet { } // determine repository and resource from url - String repository = ""; + String repository = path; Repository r = null; - int offset = 0; - while (r == null) { - int slash = path.indexOf('/', offset); - if (slash == -1) { - repository = path; - } else { - repository = path.substring(0, slash); - } - offset = ( slash + 1 ); + int terminator = repository.length(); + do { + repository = repository.substring(0, terminator); r = repositoryManager.getRepository(repository, false); - if (repository.equals(path)) { - // either only repository in url or no repository found - break; - } - } + terminator = repository.lastIndexOf('/'); + } while (r == null && terminator > -1 ); ServletContext context = request.getSession().getServletContext(); |