[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp

Jan Holesovsky kendy at collabora.com
Wed May 17 14:30:53 UTC 2017


 wsd/LOOLWSD.cpp |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 02dbc826318fef5056236d649c6bb6cdb766c03f
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed May 17 16:28:55 2017 +0200

    wsd: Don't set Content-Disposition for SVGs, the browser must handle them.
    
    Otherwise the presesntation mode downloads them instead of showing.
    
    Change-Id: If2c9785aa5ef6bbb65e911b834c77ea83da281e7
    Reviewed-on: https://gerrit.libreoffice.org/37716
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 40fd9066..1c6c91d6 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2009,10 +2009,15 @@ private:
             if (filePath.isAbsolute() && File(filePath).exists())
             {
                 // Instruct browsers to download the file, not display it
-                response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+                // with the exception of SVG where we need the browser to
+                // actually show it.
+                std::string contentType = getContentType(fileName);
+                if (contentType != "image/svg+xml")
+                    response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+
                 try
                 {
-                    HttpHelper::sendFile(socket, filePath.toString(), getContentType(fileName), response);
+                    HttpHelper::sendFile(socket, filePath.toString(), contentType, response);
                     responded = true;
                 }
                 catch (const Exception& exc)


More information about the Libreoffice-commits mailing list