[Libreoffice-commits] online.git: loolwsd/LOOLWSD.hpp loolwsd/Storage.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Mar 9 02:34:28 UTC 2016
loolwsd/LOOLWSD.hpp | 14 ++++++++------
loolwsd/Storage.hpp | 13 +++++++++----
2 files changed, 17 insertions(+), 10 deletions(-)
New commits:
commit e5fcdb890e54568aa62fbc61c3454d6f2d106758
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Tue Mar 8 19:50:35 2016 -0500
loolwsd: corrections to file and wopi URI handling
Change-Id: I7389a30931be01a40714167039055a758187bd82
Reviewed-on: https://gerrit.libreoffice.org/23053
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 77d0ea0..33f6913 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -39,12 +39,12 @@ public:
Log::info("DocumentURI: url: " + url + ", jailRoot: " + jailRoot + ", childId: " + childId);
// TODO: Sanitize the url and limit access!
- auto uriPublic = Poco::URI(url);
- uriPublic.normalize();
+ std::string decodedUrl;
+ Poco::URI::decode(url, decodedUrl);
+ auto uriPublic = Poco::URI(decodedUrl);
+ Log::info("Public URI [" + uriPublic.toString() + "].");
- const auto publicFilePath = uriPublic.getPath();
-
- if (publicFilePath.empty())
+ if (uriPublic.getPath().empty())
throw std::runtime_error("Invalid URL.");
// This lock could become a bottleneck.
@@ -62,6 +62,8 @@ public:
auto uriJailed = uriPublic;
if (uriPublic.isRelative() || uriPublic.getScheme() == "file")
{
+ uriPublic.normalize();
+ Log::info("Public URI [" + uriPublic.toString() + "] is a file.");
std::unique_ptr<StorageBase> storage(new LocalStorage(jailRoot, jailPath.toString()));
const auto localPath = storage->getFilePathFromURI(uriPublic.getPath());
uriJailed = Poco::URI(Poco::URI("file://"), localPath);
@@ -78,7 +80,7 @@ public:
auto document = std::shared_ptr<DocumentURI>(new DocumentURI(uriPublic, uriJailed, childId));
- Log::info("DocumentURI [" + publicFilePath + "] created.");
+ Log::info("DocumentURI [" + uriPublic.toString() + "] created.");
return document;
}
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index 8fcf773..5dadb9d 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -131,21 +131,26 @@ public:
/// uri format: http://server/<...>/wopi*/files/<id>/content
std::string getFilePathFromURI(const std::string& uri) override
{
+ Log::info("Downloading URI [" + uri + "].");
+
Poco::URI uriObject(uri);
Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort());
- Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uri, Poco::Net::HTTPMessage::HTTP_1_1);
- Poco::Net::HTTPResponse response;
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
session.sendRequest(request);
+ Poco::Net::HTTPResponse response;
std::istream& rs = session.receiveResponse(response);
Log::info() << "WOPI::GetFile Status: " << response.getStatus() << " " << response.getReason() << Log::end;
//TODO: Get proper filename.
- const std::string local_filename = _localStorePath + "/filename";
+ const auto filename = "filename";
+ const std::string local_filename = Poco::Path(getRootPath(), filename).toString();
std::ofstream ofs(local_filename);
std::copy(std::istreambuf_iterator<char>(rs),
std::istreambuf_iterator<char>(),
std::ostreambuf_iterator<char>(ofs));
- return local_filename;
+
+ // Now return the jailed path.
+ return Poco::Path(_jailPath, filename).toString();
}
bool restoreFileToURI(const std::string& path, const std::string& uri) override
More information about the Libreoffice-commits
mailing list