[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp

Jan Holesovsky kendy at collabora.com
Wed May 17 14:34:20 UTC 2017


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

New commits:
commit f31095690add2fd9f76e6400621892c03b441601
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/37715
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a889e42a..d7179ab2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1995,10 +1995,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