test/integration-http-server.cpp | 9 ++------- wsd/LOOLWSD.cpp | 8 ++++---- wsd/Storage.cpp | 5 +++++ wsd/Storage.hpp | 2 ++ 4 files changed, 13 insertions(+), 11 deletions(-)
New commits: commit 4ff506425faaddca85113177881630072e22cd65 Author: Tamás Zolnai <[email protected]> AuthorDate: Sat Oct 20 13:41:43 2018 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Sat Oct 20 13:41:43 2018 +0200 Enable convert-to test Change-Id: I7c2bf333bb4bcb803cd926bfb1d669f89d100615 diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp index ef8476c9e..f9d100e2f 100644 --- a/test/integration-http-server.cpp +++ b/test/integration-http-server.cpp @@ -50,7 +50,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(testLoleafletPost); CPPUNIT_TEST(testScriptsAndLinksGet); CPPUNIT_TEST(testScriptsAndLinksPost); - // FIXME CPPUNIT_TEST(testConvertTo); + CPPUNIT_TEST(testConvertTo); CPPUNIT_TEST_SUITE_END(); @@ -317,16 +317,10 @@ void HTTPServerTest::testConvertTo() form.set("format", "txt"); form.addPart("data", new Poco::Net::FilePartSource(srcPath)); form.prepareSubmit(request); - - // FIXME From some reason we are getting Poco::Net::ConnectionRefusedException - // What happens is that the file is just partially transferred - - // ConvertToPartHandler::handlePart() gets just some 3.6k bytes; no idea - // why yet form.write(session->sendRequest(request)); Poco::Net::HTTPResponse response; std::stringstream actualStream; - // receiveResponse() resulted in a Poco::Net::NoMessageException. std::istream& responseStream = session->receiveResponse(response); Poco::StreamCopier::copyStream(responseStream, actualStream); commit bb50c9e0cdcf68b010c9d312593b6dfcd4a9c93a Author: Tamás Zolnai <[email protected]> AuthorDate: Sat Oct 20 13:26:38 2018 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Sat Oct 20 13:26:38 2018 +0200 Enable convert-to features for wopi hosts Change-Id: I994be7087247215b09d117df18b661906d941266 diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 4e87c6125..c2d47ebb1 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2170,7 +2170,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" @@ -2256,7 +2256,7 @@ private: std::string format = (form.has("format") ? form.get("format") : ""); - if (!allowPostFrom(socket->clientAddress()) || StorageBase::alowedWopiHost(socket->clientAddress()) ) + if (!allowPostFrom(socket->clientAddress()) && !StorageBase::allowedWopiHost(request.getHost()) ) { LOG_ERR("client address DENY: " << socket->clientAddress()); @@ -2693,7 +2693,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(); @@ -2717,7 +2717,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()) || StorageBase::alowedWopiHost(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 722893abd..c589e988e 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -141,9 +141,9 @@ void StorageBase::initialize() #endif } -bool StorageBase::alowedWopiHost(const std::string& uri) +bool StorageBase::allowedWopiHost(const std::string& host) { - return WopiEnabled && WopiHosts.match(Poco::URI(uri).getHost()); + return WopiEnabled && WopiHosts.match(host); } #ifndef MOBILEAPP diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp index a2025a4fd..0fb906c77 100644 --- a/wsd/Storage.hpp +++ b/wsd/Storage.hpp @@ -175,7 +175,7 @@ public: const std::string& jailRoot, const std::string& jailPath); - static bool alowedWopiHost(const std::string& uri); + static bool allowedWopiHost(const std::string& host); protected: /// Returns the root path of the jail directory of docs. commit ec65ecd0f1155fcca9806e654bb760fd5b94abb1 Author: Tamás Zolnai <[email protected]> AuthorDate: Sat Oct 20 12:57:53 2018 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Sat Oct 20 12:57:53 2018 +0200 Revert "Revert "Enable convert-to features for wopi hosts"" This reverts commit 343ba48d27d6cc3bacf6d7927d9b615cd2cf98ce. diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp index e8eb1197e..ef8476c9e 100644 --- a/test/integration-http-server.cpp +++ b/test/integration-http-server.cpp @@ -173,6 +173,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 90c3e31ba..4e87c6125 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2256,7 +2256,7 @@ private: std::string format = (form.has("format") ? form.get("format") : ""); - if (!allowPostFrom(socket->clientAddress())) + if (!allowPostFrom(socket->clientAddress()) || StorageBase::alowedWopiHost(socket->clientAddress()) ) { LOG_ERR("client address DENY: " << socket->clientAddress()); @@ -2717,7 +2717,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::alowedWopiHost(socket->clientAddress()); convert_to->set("available", available); std::ostringstream ostrJSON; diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 3ceaf673e..722893abd 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -141,6 +141,11 @@ void StorageBase::initialize() #endif } +bool StorageBase::alowedWopiHost(const std::string& uri) +{ + return WopiEnabled && WopiHosts.match(Poco::URI(uri).getHost()); +} + #ifndef MOBILEAPP bool isLocalhost(const std::string& targetHost) diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp index 1e9544c2e..a2025a4fd 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 alowedWopiHost(const std::string& uri); protected: /// Returns the root path of the jail directory of docs. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
