From 8f1dc607d135fd99d769a2dfd1e11e00d72d0506 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 19 Nov 2014 11:34:17 -0500
Subject: [PATCH] Merged #223 "Add support for image/svg+xml content type to raw servlet"
---
src/main/java/com/gitblit/servlet/RawServlet.java | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java
index b11bed9..dac38f3 100644
--- a/src/main/java/com/gitblit/servlet/RawServlet.java
+++ b/src/main/java/com/gitblit/servlet/RawServlet.java
@@ -28,8 +28,6 @@
import java.util.Map;
import java.util.TreeMap;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -58,6 +56,8 @@
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* Serves the content of a branch.
@@ -108,9 +108,8 @@
branch = Repository.shortenRefName(branch).replace('/', fsc);
}
- String encodedPath = path == null ? "" : path.replace(' ', '-');
- encodedPath = encodedPath.replace('/', fsc);
- return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + (path == null ? "" : encodedPath)));
+ String encodedPath = path == null ? "" : path.replace('/', fsc);
+ return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
}
protected String getBranch(String repository, HttpServletRequest request) {
@@ -176,7 +175,7 @@
} else {
repository = path.substring(0, slash);
}
- offset += ( slash + 1 );
+ offset = ( slash + 1 );
r = repositoryManager.getRepository(repository, false);
if (repository.equals(path)) {
// either only repository in url or no repository found
@@ -249,7 +248,7 @@
}
}
- if (isTextType(contentType)) {
+ if (isTextType(contentType) || isTextDataType(contentType)) {
// load, interpret, and serve text content as UTF-8
String [] encodings = runtimeManager.getSettings().getStrings(Keys.web.blobEncodings).toArray(new String[0]);
@@ -383,6 +382,13 @@
return false;
}
+ protected boolean isTextDataType(String contentType) {
+ if ("image/svg+xml".equals(contentType)) {
+ return true;
+ }
+ return false;
+ }
+
/**
* Override all text types to be plain text.
*
--
Gitblit v1.9.1