From f6b2eaf9837a00e518b98a56ce23dd28f307b9cf Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 29 Sep 2014 11:09:05 +0200 Subject: [PATCH] OO-1212. return the right mime types of documents for most of the documents types, force download html, xhtml and javascript files only --- .../org/olat/core/util/vfs/VFSMediaResource.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/olat/core/util/vfs/VFSMediaResource.java b/src/main/java/org/olat/core/util/vfs/VFSMediaResource.java index 9a1ebec95bb..57af586c426 100644 --- a/src/main/java/org/olat/core/util/vfs/VFSMediaResource.java +++ b/src/main/java/org/olat/core/util/vfs/VFSMediaResource.java @@ -55,8 +55,16 @@ public class VFSMediaResource implements MediaResource { public String getContentType() { String mimeType; if(downloadable) { - unknownMimeType = true; - mimeType = MIME_TYPE_FORCE_DOWNLOAD; + mimeType = WebappHelper.getMimeType(vfsLeaf.getName()); + //html, xhtml and javascript are set to force download + if (mimeType == null || "text/html".equals(mimeType) + || "application/xhtml+xml".equals(mimeType) + || "application/javascript".equals(mimeType)) { + mimeType = MIME_TYPE_FORCE_DOWNLOAD; + unknownMimeType = true; + } else if (encoding != null) { + mimeType = mimeType + ";charset=" + encoding; + } } else { mimeType = WebappHelper.getMimeType(vfsLeaf.getName()); if (mimeType == null) { -- GitLab