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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu May 30 11:50:00 UTC 2019


 wsd/ClientSession.cpp |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 5663817bab022bf8c81066858d52aa931c520211
Author:     Eduard Ardeleanu <eduard-andrei.ardeleanu at 1and1.ro>
AuthorDate: Fri May 24 09:57:06 2019 +0300
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu May 30 13:49:40 2019 +0200

    detecting password protected files on convertTo
    
    Fail-fast when a file cannot be converted, using convertTo REST API, if the file is password protected and the password wasn't received.
    
    Change-Id: I32d807bcecbbe72a38a70fec74caf13638803e1d
    Reviewed-on: https://gerrit.libreoffice.org/72891
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 575515756..42e3fa2c4 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -692,6 +692,8 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
         return false;
     }
 
+    const bool isConvertTo = static_cast<bool>(_saveAsSocket);
+
 #if !MOBILEAPP
     LOOLWSD::dumpOutgoingTrace(docBroker->getJailId(), getId(), firstLine);
 #endif
@@ -748,13 +750,30 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
                     errorKind == "passwordrequired:to-modify" ||
                     errorKind == "wrongpassword")
                 {
-                    forwardToClient(payload);
+                    if (isConvertTo)
+                    {
+                        Poco::Net::HTTPResponse response;
+                        response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_UNAUTHORIZED);
+                        response.set("X-ERROR-KIND", errorKind);
+                        _saveAsSocket->send(response);
+
+                        // Conversion failed, cleanup fake session.
+                        LOG_TRC("Removing save-as ClientSession after conversion error.");
+                        // Remove us.
+                        docBroker->removeSession(getId());
+                        // Now terminate.
+                        docBroker->stop("Aborting saveas handler.");
+                    }
+                    else
+                    {
+                        forwardToClient(payload);
+                    }
                     return false;
                 }
             }
             else
             {
-                LOG_WRN("Other than load failure: " << errorKind);
+                LOG_WRN(errorCommand << " error failure: " << errorKind);
             }
         }
     }
@@ -786,7 +805,6 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
 #if !MOBILEAPP
     else if (tokens.size() == 3 && tokens[0] == "saveas:")
     {
-        bool isConvertTo = static_cast<bool>(_saveAsSocket);
 
         std::string encodedURL;
         if (!getTokenString(tokens[1], "url", encodedURL))


More information about the Libreoffice-commits mailing list