]> source.dussan.org Git - gitblit.git/commitdiff
Fix raw servlet blob paths not respecting web.forwardSlashCharacter 39/139/2
authorJames Moger <james.moger@gitblit.com>
Sat, 5 Jul 2014 17:06:24 +0000 (13:06 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 5 Jul 2014 17:24:04 +0000 (13:24 -0400)
src/main/java/com/gitblit/servlet/RawServlet.java

index 15e036ea30e61f7cacfb48c6ad2f7f55999c7d04..ff3f73596e03f160621775909425dc431596a866 100644 (file)
@@ -95,20 +95,17 @@ public class RawServlet extends DaggerServlet {
                        baseURL = baseURL.substring(0, baseURL.length() - 1);
                }
 
+               char fsc = '!';
+               char c = GitblitContext.getManager(IRuntimeManager.class).getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
+               if (c != '/') {
+                       fsc = c;
+               }
                if (branch != null) {
-                       char fsc = '!';
-                       char c = GitblitContext.getManager(IRuntimeManager.class).getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
-                       if (c != '/') {
-                               fsc = c;
-                       }
                        branch = branch.replace('/', fsc);
                }
 
                String encodedPath = path == null ? "" : path.replace(' ', '-');
-               try {
-                       encodedPath = URLEncoder.encode(encodedPath, "UTF-8");
-               } catch (UnsupportedEncodingException e) {
-               }
+               encodedPath = encodedPath.replace('/', fsc);
                return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + (path == null ? "" : encodedPath)));
        }
 
@@ -133,7 +130,8 @@ public class RawServlet extends DaggerServlet {
                if (path.endsWith("/")) {
                        path = path.substring(0, path.length() - 1);
                }
-               return path;
+               char c = runtimeManager.getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
+               return path.replace('!', '/').replace(c, '/');
        }
 
        protected boolean renderIndex() {