test/UnitWOPISaveAs.cpp | 7 ++++--- test/WopiTestServer.hpp | 2 +- wsd/ClientSession.cpp | 16 ++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-)
New commits: commit d87146d3fa1e1dd48b894ea63336822f0d271856 Author: Eduard Ardeleanu <eduard-andrei.ardele...@1and1.ro> AuthorDate: Tue Mar 19 16:00:38 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Tue Mar 19 18:31:15 2019 +0100 fix: saveAs breaks when '%' character is used within the filename Change-Id: I2df059abd67be88acae8bd44ae2c74be7778a595 Reviewed-on: https://gerrit.libreoffice.org/69424 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/test/UnitWOPISaveAs.cpp b/test/UnitWOPISaveAs.cpp index 19c9d5d17..ad79f4b59 100644 --- a/test/UnitWOPISaveAs.cpp +++ b/test/UnitWOPISaveAs.cpp @@ -34,7 +34,7 @@ public: void assertPutRelativeFileRequest(const Poco::Net::HTTPRequest& request) override { // spec says UTF-7... - CPPUNIT_ASSERT_EQUAL(std::string("/jan/hole+AWE-ovsk+AP0-/hello world.pdf"), request.get("X-WOPI-SuggestedTarget")); + CPPUNIT_ASSERT_EQUAL(std::string("/jan/hole+AWE-ovsk+AP0-/hello world+ACU-1.pdf"), request.get("X-WOPI-SuggestedTarget")); // make sure it is a pdf - or at least that it is larger than what it // used to be @@ -44,7 +44,8 @@ public: bool filterSendMessage(const char* data, const size_t len, const WSOpCode /* code */, const bool /* flush */, int& /*unitReturn*/) override { const std::string message(data, len); - const std::string expected("saveas: url=" + helpers::getTestServerURI() + "/something%20wopi/files/1?access_token=anything filename=hello%20world.pdf"); + + const std::string expected("saveas: url=" + helpers::getTestServerURI() + "/something%20wopi/files/1?access_token=anything filename=hello%20world%251.pdf"); if (message.find(expected) == 0) { // successfully exit the test if we also got the outgoing message @@ -66,7 +67,7 @@ public: initWebsocket("/wopi/files/0?access_token=anything"); helpers::sendTextFrame(*getWs()->getLOOLWebSocket(), "load url=" + getWopiSrc(), testName); - helpers::sendTextFrame(*getWs()->getLOOLWebSocket(), "saveas url=wopi:///jan/hole%C5%A1ovsk%C3%BD/hello%20world.pdf", testName); + helpers::sendTextFrame(*getWs()->getLOOLWebSocket(), "saveas url=wopi:///jan/hole%C5%A1ovsk%C3%BD/hello%20world%251.pdf", testName); SocketPoll::wakeupWorld(); _phase = Phase::Polling; diff --git a/test/WopiTestServer.hpp b/test/WopiTestServer.hpp index 1854b9c11..ea5659912 100644 --- a/test/WopiTestServer.hpp +++ b/test/WopiTestServer.hpp @@ -172,7 +172,7 @@ protected: assertPutRelativeFileRequest(request); std::string wopiURL = helpers::getTestServerURI() + "/something wopi/files/1?access_token=anything"; - std::string content = "{ \"Name\":\"hello world.pdf\", \"Url\":\"" + wopiURL + "\" }"; + std::string content = "{ \"Name\":\"hello world%1.pdf\", \"Url\":\"" + wopiURL + "\" }"; std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 7f5938bb1..9eb5cef36 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -786,12 +786,12 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt return false; } - std::string url, wopiFilename; - Poco::URI::decode(encodedURL, url); + // Save-as completed, inform the ClientSession. + std::string wopiFilename; Poco::URI::decode(encodedWopiFilename, wopiFilename); - // Save-as completed, inform the ClientSession. - Poco::URI resultURL(url); + // URI constructor implicitly decodes when it gets std::string as param + Poco::URI resultURL(encodedURL); if (resultURL.getScheme() == "file") { std::string relative(resultURL.getPath()); @@ -801,8 +801,12 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt // Rewrite file:// URLs, as they are visible to the outside world. const Path path(docBroker->getJailRoot(), relative); if (Poco::File(path).exists()) - { - resultURL.setPath(path.toString()); + { + // Encode path for special characters (i.e '%') since Poco::URI::setPath implicitly decodes the input param + std::string encodedPath; + Poco::URI::encode(path.toString(), "", encodedPath); + + resultURL.setPath(encodedPath); } else { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits