From 15f1e91fa3b058fd62cf45e572f743d21d8f1280 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 04 Sep 2014 12:16:30 -0400 Subject: [PATCH] Merged #146 "Add install script for Fedora" --- src/main/java/com/gitblit/servlet/RawServlet.java | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index f57ae2c..a9e5820 100644 --- a/src/main/java/com/gitblit/servlet/RawServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -106,10 +106,6 @@ String encodedPath = path == null ? "" : path.replace(' ', '-'); encodedPath = encodedPath.replace('/', fsc); - try { - encodedPath = URLEncoder.encode(encodedPath, "UTF-8"); - } catch (UnsupportedEncodingException e) { - } return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + (path == null ? "" : encodedPath))); } @@ -134,7 +130,8 @@ 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() { @@ -176,6 +173,9 @@ repository = path.substring(0, slash); } offset += slash; + if (offset == 0) { + offset++; + } r = repositoryManager.getRepository(repository, false); if (repository.equals(path)) { // either only repository in url or no repository found @@ -255,6 +255,15 @@ // load, interpret, and serve text content as UTF-8 String [] encodings = runtimeManager.getSettings().getStrings(Keys.web.blobEncodings).toArray(new String[0]); String content = JGitUtils.getStringContent(r, commit.getTree(), requestedPath, encodings); + if (content == null) { + logger.error("RawServlet Failed to load {} {} {}", repository, commit.getName(), path); + String str = MessageFormat.format( + "# Error\nSorry, the requested resource **{0}** was not found.", + requestedPath); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + error(response, str); + return; + } byte [] bytes = content.getBytes(Constants.ENCODING); response.setContentLength(bytes.length); -- Gitblit v1.9.1