From: Florian Zschocke Date: Mon, 9 Nov 2020 19:27:31 +0000 (+0100) Subject: raw: Fix getPath with trailing slash that was escaped X-Git-Tag: v1.9.2~37^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3212dc014c445425cc09f8d92065f1afb4e53065;p=gitblit.git raw: Fix getPath with trailing slash that was escaped While this may be an unlikely scenario, let's still prevent this. When a link was created for a path that ends in a trailing slash, that trailing slash would be replaced with the `forwardSlashCharacter`. But in getPath that final slash would be transformed back *after* the check to chop off trailing slashes. This is now switched so that such a trailing slash is also chopped off. --- diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index 90e8ac74..b0cba787 100644 --- a/src/main/java/com/gitblit/servlet/RawServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -179,14 +179,18 @@ public class RawServlet extends HttpServlet { // 'leadin/repository/branch/' if (pathStart < pathInfo.length() && pathInfo.charAt(pathStart) == '/') pathStart++; if (pathInfo.length() == pathStart) return ""; + // 'leadin/repository/branch/path' String path = pathInfo.substring(pathStart); + + char c = runtimeManager.getSettings().getChar(Keys.web.forwardSlashCharacter, '/'); + path = path.replace('!', '/').replace(c, '/'); + + // 'repository/branch/path/' // 'leadin/repository/branch/path/' if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } - // 'leadin/repository/branch/path' - char c = runtimeManager.getSettings().getChar(Keys.web.forwardSlashCharacter, '/'); - return path.replace('!', '/').replace(c, '/'); + return path; } protected boolean renderIndex() {