[Libreoffice-commits] online.git: loolwsd/DocumentBroker.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Mar 14 03:14:29 UTC 2016


 loolwsd/DocumentBroker.hpp |   37 ++++---------------------------------
 1 file changed, 4 insertions(+), 33 deletions(-)

New commits:
commit 1aa7a6cf05526282f93516713a1bfee143e1c3f8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Mar 13 10:05:40 2016 -0400

    loolwsd: simplified DocumentBroker::create
    
    Change-Id: Ia97be0861c7c178859d695ae5e2862e88cb3ca77
    Reviewed-on: https://gerrit.libreoffice.org/23221
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index f4fc674..544efbb 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -27,8 +27,10 @@ class DocumentBroker
 public:
 
     static
-    Poco::URI getUri(std::string uri)
+    std::shared_ptr<DocumentBroker> create(std::string uri, const std::string& childRoot)
     {
+        Log::info("Creating DocumentBroker for uri: " + uri + ".");
+
         // The URI of the document is url-encoded
         // and passed in our URL.
         if (uri.size() > 1 && uri[0] == '/')
@@ -47,42 +49,11 @@ public:
             uriPublic.normalize();
         }
 
-        Log::info("Public URI [" + uriPublic.toString() + "].");
         if (uriPublic.getPath().empty())
         {
             throw std::runtime_error("Invalid URI.");
         }
 
-        return uriPublic;
-    }
-
-    static
-    std::shared_ptr<DocumentBroker> create(const std::string& uri, const std::string& childRoot)
-    {
-        std::string decodedUri;
-        Poco::URI::decode(uri, decodedUri);
-        auto uriPublic = Poco::URI(decodedUri);
-
-        if (uriPublic.isRelative() || uriPublic.getScheme() == "file")
-        {
-            // TODO: Validate and limit access to local paths!
-            uriPublic.normalize();
-        }
-
-        Log::info("Public URI [" + uriPublic.toString() + "].");
-        if (uriPublic.getPath().empty())
-        {
-            throw std::runtime_error("Invalid URI.");
-        }
-
-        return create(uriPublic, childRoot);
-    }
-
-    static
-    std::shared_ptr<DocumentBroker> create(const Poco::URI& uriPublic, const std::string& childRoot)
-    {
-        Log::info("Creating DocumentBroker for uri: " + uriPublic.toString());
-
         std::string docKey;
         Poco::URI::encode(uriPublic.getPath(), "", docKey);
 
@@ -168,7 +139,7 @@ private:
     {
         assert(!_docKey.empty());
         assert(!_childRoot.empty());
-        Log::info("DocumentBroker [" + _uriPublic.toString() + "] created.");
+        Log::info("DocumentBroker [" + _uriPublic.toString() + "] created. DocKey: [" + _docKey + "]");
     }
 
 private:


More information about the Libreoffice-commits mailing list