loleaflet/Makefile | 1 loleaflet/debug/document/admin.html | 2 - loleaflet/debug/document/adminAnalytics.html | 2 - loleaflet/debug/document/adminSettings.html | 2 - loleaflet/dist/admin/admin.html | 4 +-- loleaflet/dist/admin/adminAnalytics.html | 4 +-- loleaflet/dist/admin/adminSettings.html | 4 +-- loleaflet/src/control/Toolbar.js | 6 ++--- loleaflet/src/core/Socket.js | 2 - loleaflet/src/layer/tile/TileLayer.js | 2 - loleaflet/src/map/Map.js | 3 +- loleaflet/src/map/handler/Map.FileInserter.js | 2 - loolwsd/FileServer.hpp | 2 - loolwsd/LOOLWSD.cpp | 31 ++++++++++++++++---------- loolwsd/test/UnitAdmin.cpp | 8 +++--- loolwsd/test/helpers.hpp | 2 - loolwsd/test/httpwstest.cpp | 8 +++--- 17 files changed, 48 insertions(+), 37 deletions(-)
New commits: commit 702cc0603f9e8a98553566fe173cdc75f87a8924 Author: Andras Timar <andras.ti...@collabora.com> Date: Thu Jun 9 15:26:08 2016 +0200 loleaflet: l10n of src/control/Toolbar.js (cherry picked from commit ec15d9e9fff3eb40e6841d3d5e659d7f3719e5ca) diff --git a/loleaflet/Makefile b/loleaflet/Makefile index 4cb0fd1..e826fa2 100644 --- a/loleaflet/Makefile +++ b/loleaflet/Makefile @@ -40,6 +40,7 @@ pot: src/admin/Util.js \ src/control/Control.Menubar.js \ src/control/Control.Tabs.js \ + src/control/Toolbar.js \ src/core/Socket.js \ src/map/Map.js diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js index cee4561..5ec6050 100644 --- a/loleaflet/src/control/Toolbar.js +++ b/loleaflet/src/control/Toolbar.js @@ -40,7 +40,7 @@ L.Map.include({ } id = id || -1; // not a special download - this.showBusy('Downloading...', false); + this.showBusy(_('Downloading...'), false); this._socket.sendMessage('downloadas ' + 'name=' + name + ' ' + 'id=' + id + ' ' + @@ -49,7 +49,7 @@ L.Map.include({ }, print: function () { - this.showBusy('Downloading...', false); + this.showBusy(_('Downloading...'), false); this.downloadAs('print.pdf', 'pdf', null, 'print'); }, @@ -61,7 +61,7 @@ L.Map.include({ options = ''; } - this.showBusy('Saving...', false); + this.showBusy(_('Saving...'), false); // TakeOwnership: we are performing a 'real' save-as, the document // is just getting a new place, ie. it will get the // '.uno:ModifiedStatus' upon completion. commit 4cfde6c901391b083166e194ac6cd7862f59f7b0 Author: Pranav Kant <pran...@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.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> (cherry picked from commit 257b95f01f0d21ed352e1d199137cc4a5ad9d8bb) 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 162c1c0..6deef34 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 fe5dcc5..192c332 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -346,7 +346,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); @@ -443,7 +443,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", "*"); @@ -472,15 +472,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); @@ -812,7 +812,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 b334725..9b68d6c 100644 --- a/loolwsd/test/httpwstest.cpp +++ b/loolwsd/test/httpwstest.cpp @@ -1167,7 +1167,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); commit 54ae631bd288063d53a69ee8e6f3d70db34d1d37 Author: Pranav Kant <pran...@collabora.com> Date: Wed Jun 8 15:51:29 2016 +0530 bccu#1871: Add url prefix to websocket urls Normal websocket connections are now : /lool/ws/filename Admin websocket is now : /lool/adminws/ Change-Id: If39382cb852d89ed0394adbd7fe168fe4767a075 Reviewed-on: https://gerrit.libreoffice.org/26029 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> (cherry picked from commit 8cc367638f7a0e5da56905510dda76075401cb4e) diff --git a/loleaflet/debug/document/admin.html b/loleaflet/debug/document/admin.html index 98bc593..891dab8 100644 --- a/loleaflet/debug/document/admin.html +++ b/loleaflet/debug/document/admin.html @@ -37,7 +37,7 @@ <script>vex.defaultOptions.className = 'vex-theme-plain';</script> <script> - var host = 'wss://' + window.location.host + '/adminws/'; + var host = 'wss://' + window.location.host + '/lool/adminws/'; new AdminSocketOverview(host); </script> diff --git a/loleaflet/debug/document/adminAnalytics.html b/loleaflet/debug/document/adminAnalytics.html index 13c124c..1841c56 100644 --- a/loleaflet/debug/document/adminAnalytics.html +++ b/loleaflet/debug/document/adminAnalytics.html @@ -38,7 +38,7 @@ <script src="../../dist/admin/admin-src.js"></script> <script> - host = 'wss://' + window.location.host + '/adminws/'; + host = 'wss://' + window.location.host + '/lool/adminws/'; new AdminSocketAnalytics(host); </script> diff --git a/loleaflet/debug/document/adminSettings.html b/loleaflet/debug/document/adminSettings.html index a86b137..5cd3bbc 100644 --- a/loleaflet/debug/document/adminSettings.html +++ b/loleaflet/debug/document/adminSettings.html @@ -37,7 +37,7 @@ <script src="../../dist/admin/admin-src.js"></script> <script> - host = 'wss://' + window.location.host + '/adminws/'; + host = 'wss://' + window.location.host + '/lool/adminws/'; new AdminSocketSettings(host); </script> diff --git a/loleaflet/dist/admin/admin.html b/loleaflet/dist/admin/admin.html index ef4a209..a3369fc 100644 --- a/loleaflet/dist/admin/admin.html +++ b/loleaflet/dist/admin/admin.html @@ -44,10 +44,10 @@ <script> if (window.location.protocol == "https:") { - host = 'wss://' + window.location.host + '/adminws/' + host = 'wss://' + window.location.host + '/lool/adminws/' } else { - host = 'ws://' + window.location.host + '/adminws/' + host = 'ws://' + window.location.host + '/lool/adminws/' } new AdminSocketOverview(host); diff --git a/loleaflet/dist/admin/adminAnalytics.html b/loleaflet/dist/admin/adminAnalytics.html index 23ad622..bef4e00 100644 --- a/loleaflet/dist/admin/adminAnalytics.html +++ b/loleaflet/dist/admin/adminAnalytics.html @@ -46,10 +46,10 @@ <script> if (window.location.protocol == "https:") { - host = 'wss://' + window.location.host + '/adminws/' + host = 'wss://' + window.location.host + '/lool/adminws/' } else { - host = 'ws://' + window.location.host + '/adminws/' + host = 'ws://' + window.location.host + '/lool/adminws/' } new AdminSocketAnalytics(host); diff --git a/loleaflet/dist/admin/adminSettings.html b/loleaflet/dist/admin/adminSettings.html index 351d4c0..54d5f31 100644 --- a/loleaflet/dist/admin/adminSettings.html +++ b/loleaflet/dist/admin/adminSettings.html @@ -45,10 +45,10 @@ <script> if (window.location.protocol == "https:") { - host = 'wss://' + window.location.host + '/adminws/' + host = 'wss://' + window.location.host + '/lool/adminws/' } else { - host = 'ws://' + window.location.host + '/adminws/' + host = 'ws://' + window.location.host + '/lool/adminws/' } new AdminSocketSettings(host); diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index bbd68e2..49092c8 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -9,7 +9,7 @@ L.Socket = L.Class.extend({ initialize: function (map) { this._map = map; try { - this.socket = new WebSocket(map.options.server + '/' + map.options.doc); + this.socket = new WebSocket(map.options.server + '/lool/ws/' + map.options.doc); } catch (e) { this.fire('error', {msg: _('Oops, there is a problem connecting to LibreOffice Online : ' + e), cmd: 'socket', kind: 'failed', id: 3}); return null; diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp index da09978..a4ca0b8 100644 --- a/loolwsd/FileServer.hpp +++ b/loolwsd/FileServer.hpp @@ -99,7 +99,7 @@ public: JWTAuth authAgent(sslKeyPath, "admin", "admin", "admin"); const std::string jwtToken = authAgent.getAccessToken(); Poco::Net::HTTPCookie cookie("jwt", jwtToken); - cookie.setPath("/adminws/"); + cookie.setPath("/lool/adminws/"); cookie.setSecure(true); cookie.setHttpOnly(true); response.addCookie(cookie); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 65d5c3d..fe5dcc5 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -518,9 +518,12 @@ private: // Remove the leading '/' in the GET URL. std::string uri = request.getURI(); if (uri.size() > 0 && uri[0] == '/') - { uri.erase(0, 1); - } + + // Remove leading 'lool/ws/' from GET URL + if (uri.size() > 0 && uri.compare(0, 8, "lool/ws/") == 0) + uri.erase(0, 8); + const auto uriPublic = DocumentBroker::sanitizeURI(uri); const auto docKey = DocumentBroker::getDocKey(uriPublic); @@ -793,6 +796,10 @@ public: { const auto id = LOOLWSD::GenSessionId(); + Poco::URI requestUri(request.getURI()); + std::vector<std::string> reqPathSegs; + requestUri.getPathSegments(reqPathSegs); + Util::setThreadName("client_ws_" + id); Log::debug("Thread started."); @@ -809,7 +816,7 @@ public: { responded = handlePostRequest(request, response, id); } - else + else if (reqPathSegs.size() > 2 && reqPathSegs[0] == "lool" && reqPathSegs[1] == "ws") { auto ws = std::make_shared<WebSocket>(request, response); try @@ -1097,7 +1104,7 @@ public: requestHandler = _fileServer.createRequestHandler(); } // Admin WebSocket Connections - else if (reqPathSegs.size() >= 1 && reqPathSegs[0] == "adminws") + else if (reqPathSegs.size() >= 2 && reqPathSegs[0] == "lool" && reqPathSegs[1] == "adminws") { requestHandler = Admin::createRequestHandler(); } diff --git a/loolwsd/test/UnitAdmin.cpp b/loolwsd/test/UnitAdmin.cpp index 2ecd27a..7ba4ffe 100644 --- a/loolwsd/test/UnitAdmin.cpp +++ b/loolwsd/test/UnitAdmin.cpp @@ -113,7 +113,7 @@ private: bool httpOnly = cookies[0].getHttpOnly(); std::string value = cookies[0].getValue(); TestResult res = TestResult::TEST_FAILED; - if (cookiePath.find_first_of("/adminws/") == 0 && + if (cookiePath.find_first_of("/lool/adminws/") == 0 && secure && httpOnly && value != "") @@ -156,7 +156,7 @@ private: TestResult testWebSocketWithCookie() { HTTPResponse response; - HTTPRequest request(HTTPRequest::HTTP_GET, "/adminws/"); + HTTPRequest request(HTTPRequest::HTTP_GET, "/lool/adminws/"); std::unique_ptr<HTTPClientSession> session(helpers::createSession(_uri)); // set cookie @@ -192,7 +192,7 @@ private: _adminWs->sendFrame(subscribeMessage.data(), subscribeMessage.size()); const std::string documentPath1 = Util::getTempFilePath(TDOC, "hello.odt"); - const std::string documentURL1 = "file://" + Poco::Path(documentPath1).makeAbsolute().toString(); + const std::string documentURL1 = std::string("lool/ws/") + "file://" + Poco::Path(documentPath1).makeAbsolute().toString(); HTTPRequest request1(HTTPRequest::HTTP_GET, documentURL1); HTTPResponse response1; const Poco::URI docUri1(helpers::getTestServerURI()); @@ -262,7 +262,7 @@ private: // Open another document (different) const std::string documentPath2 = Util::getTempFilePath(TDOC, "insert-delete.odp"); - const std::string documentURL2 = "file://" + Poco::Path(documentPath2).makeAbsolute().toString(); + const std::string documentURL2 = std::string("lool/ws/") + "file://" + Poco::Path(documentPath2).makeAbsolute().toString(); HTTPRequest request2(HTTPRequest::HTTP_GET, documentURL2); HTTPResponse response2; const Poco::URI docUri2(helpers::getTestServerURI()); diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp index 2483049..3214e58 100644 --- a/loolwsd/test/helpers.hpp +++ b/loolwsd/test/helpers.hpp @@ -52,7 +52,7 @@ inline void getDocumentPathAndURL(const char* document, std::string& documentPath, std::string& documentURL) { documentPath = Util::getTempFilePath(TDOC, document); - documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString(); + documentURL = "lool/ws/file://" + Poco::Path(documentPath).makeAbsolute().toString(); std::cerr << "Test file: " << documentPath << std::endl; } diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp index 7328115..b334725 100644 --- a/loolwsd/test/httpwstest.cpp +++ b/loolwsd/test/httpwstest.cpp @@ -181,7 +181,7 @@ void HTTPWSTest::testBadRequest() try { // Load a document and get its status. - const std::string documentURL = "file:///fake.doc"; + const std::string documentURL = "lool/ws/file:///fake.doc"; Poco::Net::HTTPResponse response; Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); @@ -894,7 +894,7 @@ void HTTPWSTest::testPasswordProtectedDocumentWithCorrectPassword() try { const std::string documentPath = Util::getTempFilePath(TDOC, "password-protected.ods"); - const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString(); + const std::string documentURL = "lool/ws/file://" + Poco::Path(documentPath).makeAbsolute().toString(); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); Poco::Net::WebSocket socket = *connectLOKit(_uri, request, _response); @@ -1019,7 +1019,7 @@ void HTTPWSTest::testInsertDelete() void HTTPWSTest::testEditLock() { const std::string documentPath = Util::getTempFilePath(TDOC, "hello.odt"); - const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString(); + const std::string documentURL = "lool/ws/file://" + Poco::Path(documentPath).makeAbsolute().toString(); std::mutex mutex; std::condition_variable cv; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits