[Libreoffice-commits] online.git: loleaflet/src loolwsd/LOOLWSD.cpp loolwsd/test

Pranav Kant pranavk at collabora.com
Thu Jun 9 11:22:24 UTC 2016


 loleaflet/src/layer/tile/TileLayer.js         |    2 +-
 loleaflet/src/map/Map.js                      |    3 ++-
 loleaflet/src/map/handler/Map.FileInserter.js |    2 +-
 loolwsd/LOOLWSD.cpp                           |   16 +++++++++-------
 loolwsd/test/httpwstest.cpp                   |    2 +-
 5 files changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 257b95f01f0d21ed352e1d199137cc4a5ad9d8bb
Author: Pranav Kant <pranavk at collabora.com>
Date:   Thu Jun 9 14:06:45 2016 +0530

    bccu#1871: Add url prefix, lool, to post requests
    
    All post requests will now have to be prefixed with /lool/
    
    This is necessary to ease proxy url redirection setup.
    
    Change-Id: I04fbc211879722f6433cb9eb17786f394187a1b9
    Reviewed-on: https://gerrit.libreoffice.org/26091
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index df233d6..81d5553 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -378,7 +378,7 @@ L.TileLayer = L.GridLayer.extend({
 		var command = this._map._socket.parseServerCmd(textMsg);
 		var parser = document.createElement('a');
 		parser.href = this._map.options.server;
-		var url = this._map.options.webserver + '/' +
+		var url = this._map.options.webserver + '/' + this._map.options.urlPrefix + '/' +
 			command.jail + '/' + command.dir + '/' + command.name;
 
 		this._map.hideBusy();
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 099d284..b57d3ae 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -16,7 +16,8 @@ L.Map = L.Evented.extend({
 		markerZoomAnimation: true,
 		defaultZoom: 10,
 		tileWidthTwips: 3840,
-		tileHeightTwips: 3840
+		tileHeightTwips: 3840,
+		urlPrefix: 'lool'
 	},
 
 	initialize: function (id, options) { // (HTMLElement or String, Object)
diff --git a/loleaflet/src/map/handler/Map.FileInserter.js b/loleaflet/src/map/handler/Map.FileInserter.js
index 3d76d78..7e90a2a 100644
--- a/loleaflet/src/map/handler/Map.FileInserter.js
+++ b/loleaflet/src/map/handler/Map.FileInserter.js
@@ -14,7 +14,7 @@ L.Map.FileInserter = L.Handler.extend({
 		this._toInsert = {};
 		var parser = document.createElement('a');
 		parser.href = map.options.server;
-		this._url = map.options.webserver + '/insertfile';
+		this._url = map.options.webserver + '/' + map.options.urlPrefix + '/insertfile';
 	},
 
 	addHooks: function () {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index c5d8743..c6d1d63 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -349,7 +349,7 @@ private:
     {
         Log::info("Post request: [" + request.getURI() + "]");
         StringTokenizer tokens(request.getURI(), "/?");
-        if (tokens.count() >= 2 && tokens[1] == "convert-to")
+        if (tokens.count() >= 3 && tokens[2] == "convert-to")
         {
             std::string fromPath;
             ConvertToPartHandler handler(fromPath);
@@ -452,7 +452,7 @@ private:
 
             return true;
         }
-        else if (tokens.count() >= 2 && tokens[1] == "insertfile")
+        else if (tokens.count() >= 3 && tokens[2] == "insertfile")
         {
             Log::info("Insert file request.");
             response.set("Access-Control-Allow-Origin", "*");
@@ -481,15 +481,15 @@ private:
                 }
             }
         }
-        else if (tokens.count() >= 4)
+        else if (tokens.count() >= 5)
         {
             Log::info("File download request.");
             // The user might request a file to download
             //TODO: Check that the user in question has access to this file!
-            const std::string dirPath = LOOLWSD::ChildRoot + tokens[1]
-                                      + JAILED_DOCUMENT_ROOT + tokens[2];
+            const std::string dirPath = LOOLWSD::ChildRoot + tokens[2]
+                                      + JAILED_DOCUMENT_ROOT + tokens[3];
             std::string fileName;
-            URI::decode(tokens[3], fileName);
+            URI::decode(tokens[4], fileName);
             const std::string filePath = dirPath + "/" + fileName;
             Log::info("HTTP request for: " + filePath);
             File file(filePath);
@@ -821,7 +821,9 @@ public:
                 // http://server/hosting/discovery
                 responded = handleGetWOPIDiscovery(request, response);
             }
-            else if (!(request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0))
+            // All post requests have url prefix, lool
+            else if (!(request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0) &&
+                     reqPathSegs[0] == "lool")
             {
                 responded = handlePostRequest(request, response, id);
             }
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index b723b3c..cef99e7 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -1092,7 +1092,7 @@ void HTTPWSTest::testSlideShow()
             CPPUNIT_ASSERT_EQUAL(static_cast<int>(_uri.getPort()), port);
             CPPUNIT_ASSERT_EQUAL(std::string("slideshow"), id);
 
-            const std::string path = "/" + jail + "/" + dir + "/" + name + "?mime_type=image/svg%2Bxml";
+            const std::string path = "/lool/" + jail + "/" + dir + "/" + name + "?mime_type=image/svg%2Bxml";
             std::unique_ptr<Poco::Net::HTTPClientSession> session(helpers::createSession(_uri));
             Poco::Net::HTTPRequest requestSVG(Poco::Net::HTTPRequest::HTTP_GET, path);
             session->sendRequest(requestSVG);


More information about the Libreoffice-commits mailing list