Milos Cubrilo
2015-01-11 a9a2ffcf9a34bd25fe2e05bfdd4cde74725bb17d
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.
@@ -234,9 +234,18 @@
            // requested a specific resource
            String file = StringUtils.getLastPathElement(requestedPath);
            try {
               // query Tika for the content type
               Tika tika = new Tika();
               String contentType = tika.detect(file);
               String contentType;
               List<String> exts = runtimeManager.getSettings().getStrings(Keys.web.prettyPrintExtensions);
               String ext = StringUtils.getFileExtension(file).toLowerCase();
               if (exts.contains(ext)) {
                  // extension is a registered text type for pretty printing
                  contentType = "text/plain";
               } else {
                  // query Tika for the content type
                  Tika tika = new Tika();
                  contentType = tika.detect(file);
               }
               if (contentType == null) {
                  // ask the container for the content type
@@ -248,7 +257,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]);
@@ -382,6 +391,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.
    *