diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2021-12-08 11:52:13 +0300 |
---|---|---|
committer | Ashod Nakashian <Ashod@users.noreply.github.com> | 2021-12-08 10:40:26 -0500 |
commit | a809df68b0a166d1c3e050c10e3723e90c5baabf (patch) | |
tree | 83aaf0d478a76036560b89fda3a1f4037db20e5a | |
parent | make stringifyHexLine() simply work on std::string (diff) | |
download | online-a809df68b0a166d1c3e050c10e3723e90c5baabf.tar.gz online-a809df68b0a166d1c3e050c10e3723e90c5baabf.zip |
fix double encoding url on convert-to
Problem is, all save-as requests received urlencoded
but when it is a wopi request we change the url bit of the message
with correct path jail filename parts. At that stage it becomes decoded
already. saveAs in the core also decodes the url and thats why we should
re-encode it. But unless it is a wopi request it should be already
encoded and we should not re-encode it again.
Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I08b3a1cff6c3aa9271222c255f4a35aa5b984819
-rw-r--r-- | kit/ChildSession.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 87a00c7bf2..e48a6f2df3 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -2339,6 +2339,7 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const StringVe // if the url is a 'wopi:///something/blah.odt', then save to a temporary Poco::URI wopiURL(url); + bool encodeURL = false; if (wopiURL.getScheme() == "wopi") { std::vector<std::string> pathSegments; @@ -2360,6 +2361,9 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const StringVe const std::string tmpDir = FileUtil::createRandomDir(jailDoc); const Poco::Path filenameParam(pathSegments[pathSegments.size() - 1]); url = std::string("file://") + jailDoc + tmpDir + '/' + filenameParam.getFileName(); + // url becomes decoded at this stage + // on saveAs we should send encoded! + encodeURL = true; wopiFilename = wopiURL.getPath(); } @@ -2391,8 +2395,14 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const StringVe getLOKitDocument()->setView(_viewId); - std::string encodedURL, encodedWopiFilename; - Poco::URI::encode(url, "", encodedURL); + std::string encodedURL; + if (encodeURL) + Poco::URI::encode(url, "", encodedURL); + else + // url is already encoded + encodedURL = url; + + std::string encodedWopiFilename; Poco::URI::encode(wopiFilename, "", encodedWopiFilename); success = getLOKitDocument()->saveAs(encodedURL.c_str(), |