[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - test/integration-http-server.cpp wsd/LOOLWSD.cpp wsd/Storage.cpp wsd/Storage.hpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 8 21:09:24 UTC 2018


 test/integration-http-server.cpp |    1 +
 wsd/LOOLWSD.cpp                  |    8 ++++----
 wsd/Storage.cpp                  |    5 +++++
 wsd/Storage.hpp                  |    2 ++
 4 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 01a43feafbbb6ca3b5ad06e82705e90aea556458
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Oct 20 12:57:53 2018 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Nov 8 22:09:06 2018 +0100

    Enable convert-to features for wopi hosts
    
    Change-Id: I994be7087247215b09d117df18b661906d941266
    (cherry picked from commit bb50c9e0cdcf68b010c9d312593b6dfcd4a9c93a)
    Reviewed-on: https://gerrit.libreoffice.org/62401
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp
index 16d002de6..4a1c425ad 100644
--- a/test/integration-http-server.cpp
+++ b/test/integration-http-server.cpp
@@ -169,6 +169,7 @@ void HTTPServerTest::testCapabilities()
 
         Poco::JSON::Object::Ptr convert_to = features->get("convert-to").extract<Poco::JSON::Object::Ptr>();
         CPPUNIT_ASSERT(convert_to->has("available"));
+        CPPUNIT_ASSERT(convert_to->get("available"));
     }
 }
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 68472329d..7d0e0eb33 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2053,7 +2053,7 @@ private:
     {
         LOG_DBG("Wopi capabilities request: " << request.getURI());
 
-        std::string capabilities = getCapabilitiesJson();
+        std::string capabilities = getCapabilitiesJson(request.getHost());
 
         std::ostringstream oss;
         oss << "HTTP/1.1 200 OK\r\n"
@@ -2139,7 +2139,7 @@ private:
 
             std::string format = (form.has("format") ? form.get("format") : "");
 
-            if (!allowPostFrom(socket->clientAddress()))
+            if (!allowPostFrom(socket->clientAddress()) && !StorageBase::allowedWopiHost(request.getHost()) )
             {
                 LOG_ERR("client address DENY: " << socket->clientAddress().c_str());
                 std::ostringstream oss;
@@ -2567,7 +2567,7 @@ private:
     }
 
     /// Process the capabilities.json file and return as string.
-    std::string getCapabilitiesJson()
+    std::string getCapabilitiesJson(const std::string& host)
     {
         std::shared_ptr<StreamSocket> socket = _socket.lock();
 
@@ -2591,7 +2591,7 @@ private:
         Poco::JSON::Object::Ptr features = jsonFile.extract<Poco::JSON::Object::Ptr>();
         Poco::JSON::Object::Ptr convert_to = features->get("convert-to").extract<Poco::JSON::Object::Ptr>();
 
-        Poco::Dynamic::Var available = allowPostFrom(socket->clientAddress());
+        Poco::Dynamic::Var available = allowPostFrom(socket->clientAddress()) || StorageBase::allowedWopiHost(host);
         convert_to->set("available", available);
 
         std::ostringstream ostrJSON;
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 3e2e23ad6..05403dd46 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -131,6 +131,11 @@ void StorageBase::initialize()
 #endif
 }
 
+bool StorageBase::allowedWopiHost(const std::string& host)
+{
+    return WopiEnabled && WopiHosts.match(host);
+}
+
 bool isLocalhost(const std::string& targetHost)
 {
     std::string targetAddress;
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index f061f818b..cbb6f9c42 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -174,6 +174,8 @@ public:
     static std::unique_ptr<StorageBase> create(const Poco::URI& uri,
                                                const std::string& jailRoot,
                                                const std::string& jailPath);
+
+    static bool allowedWopiHost(const std::string& host);
 protected:
 
     /// Returns the root path of the jail directory of docs.


More information about the Libreoffice-commits mailing list