summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJoel Johnson <mrjoel@lixil.net>2015-12-09 15:58:33 -0700
committerJoel Johnson <mrjoel@lixil.net>2015-12-09 15:58:33 -0700
commit68100a26901a46dac6fef6dc0b1dc473c0f5793f (patch)
tree97053f4d205db68ce9fc298e104f4d0d0e526834 /src/main/java
parentf7e28a481bcf86070b829e2574b6d5202124bb0a (diff)
downloadgitblit-68100a26901a46dac6fef6dc0b1dc473c0f5793f.tar.gz
gitblit-68100a26901a46dac6fef6dc0b1dc473c0f5793f.zip
revise logic for forcing dotfile to text
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/servlet/RawServlet.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java
index 81793bc7..897047d8 100644
--- a/src/main/java/com/gitblit/servlet/RawServlet.java
+++ b/src/main/java/com/gitblit/servlet/RawServlet.java
@@ -233,7 +233,14 @@ public class RawServlet extends HttpServlet {
try {
String ext = StringUtils.getFileExtension(file).toLowerCase();
- String contentType = file.charAt(0) == '.' ? "text/plain" : quickContentTypes.get(ext);
+ // We can't parse out an extension for classic "dotfiles", so make a general assumption that
+ // they're text files to allow presenting them in browser instead of only for download.
+ //
+ // However, that only holds for files with no other extension included, for files that happen
+ // to start with a dot but also include an extension, process the extension normally.
+ // This logic covers .gitattributes, .gitignore, .zshrc, etc., but does not cover .mongorc.js, .zshrc.bak
+ boolean isExtensionlessDotfile = file.charAt(0) == '.' && (file.length() == 1 || file.indexOf('.', 1) < 0);
+ String contentType = isExtensionlessDotfile ? "text/plain" : quickContentTypes.get(ext);
if (contentType == null) {
List<String> exts = runtimeManager.getSettings().getStrings(Keys.web.prettyPrintExtensions);