[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/dist loolwsd.xml.in wsd/FileServer.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Sep 10 20:59:38 UTC 2018
loleaflet/dist/loleaflet.html | 14 +++++++-------
loolwsd.xml.in | 1 +
wsd/FileServer.cpp | 1 +
wsd/LOOLWSD.cpp | 16 ++++++++++++++++
wsd/LOOLWSD.hpp | 1 +
5 files changed, 26 insertions(+), 7 deletions(-)
New commits:
commit 6d09c64f355152d322bf43ba4760627a1bb68f6b
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Sep 7 00:25:50 2018 +0200
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Sep 10 22:59:19 2018 +0200
ServiceRoot: Allow prefixing all the URI paths with a given prefix.
For instances that has to run in a deeper path like
https://server/something/blah/loleaflet/HASH/loleaflet.html.
Change-Id: Idacdaf9087d682fd527c3af2ea45d6b51a33908e
Reviewed-on: https://gerrit.libreoffice.org/60173
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index 3a3424c79..ce9cdcb74 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -19,10 +19,10 @@
window.addEventListener('message', PostMessageReadyListener, false);
</script>
<!--%BRANDING_CSS%--> <!-- add your logo here -->
-<link rel="localizations" href="/loleaflet/%VERSION%/l10n/localizations.json" type="application/vnd.oftn.l10n+json"/>
-<link rel="localizations" href="/loleaflet/%VERSION%/l10n/locore-localizations.json" type="application/vnd.oftn.l10n+json" />
-<link rel="localizations" href="/loleaflet/%VERSION%/l10n/help-localizations.json" type="application/vnd.oftn.l10n+json"/>
-<link rel="localizations" href="/loleaflet/%VERSION%/l10n/uno-localizations.json" type="application/vnd.oftn.l10n+json" />
+<link rel="localizations" href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/localizations.json" type="application/vnd.oftn.l10n+json"/>
+<link rel="localizations" href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/locore-localizations.json" type="application/vnd.oftn.l10n+json" />
+<link rel="localizations" href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/help-localizations.json" type="application/vnd.oftn.l10n+json"/>
+<link rel="localizations" href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/uno-localizations.json" type="application/vnd.oftn.l10n+json" />
<body style="user-select: none;">
<!--The "controls" div holds map controls such as the Zoom button and
it's separated from the map in order to have the controls on the top
@@ -104,7 +104,7 @@
window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
</script>
<!--%BRANDING_JS%--> <!-- logo onclick handler -->
- <script src="/loleaflet/%VERSION%/bundle.js"></script>
- <script src="/loleaflet/%VERSION%/toolbar/w2ui-1.5.rc1.min.js"></script>
- <script src="/loleaflet/%VERSION%/toolbar/toolbar.js"></script>
+ <script src="%SERVICE_ROOT%/loleaflet/%VERSION%/bundle.js"></script>
+ <script src="%SERVICE_ROOT%/loleaflet/%VERSION%/toolbar/w2ui-1.5.rc1.min.js"></script>
+ <script src="%SERVICE_ROOT%/loleaflet/%VERSION%/toolbar/toolbar.js"></script>
</body></html>
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index 7aae4c8d6..74414de97 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -68,6 +68,7 @@
<net desc="Network settings">
<proto type="string" default="all" desc="Protocol to use IPv4, IPv6 or all for both">all</proto>
+ <service_root type="path" default="" desc="Prefix all the pages, websockets, etc. with this path."></service_root>
</net>
<ssl desc="SSL settings">
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index d7fc0df7b..afd7f63af 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -614,6 +614,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco::
Poco::replaceInPlace(preprocess, std::string("%ACCESS_HEADER%"), escapedAccessHeader);
Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
Poco::replaceInPlace(preprocess, std::string("%VERSION%"), std::string(LOOLWSD_VERSION_HASH));
+ Poco::replaceInPlace(preprocess, std::string("%SERVICE_ROOT%"), LOOLWSD::ServiceRoot);
static const std::string linkCSS("<link rel=\"stylesheet\" href=\"/loleaflet/" LOOLWSD_VERSION_HASH "/%s.css\">");
static const std::string scriptJS("<script src=\"/loleaflet/" LOOLWSD_VERSION_HASH "/%s.js\"></script>");
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 404597676..087abbd27 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -553,6 +553,7 @@ inline std::string getLaunchURI()
std::ostringstream oss;
oss << getLaunchBase("");
+ oss << LOOLWSD::ServiceRoot;
oss << LOOLWSD_TEST_LOLEAFLET_UI;
oss << "?file_path=file://";
oss << Poco::Path(aAbsTopSrcDir).absolute().toString();
@@ -597,6 +598,7 @@ std::string LOOLWSD::LoTemplate;
std::string LOOLWSD::ChildRoot;
std::string LOOLWSD::ServerName;
std::string LOOLWSD::FileServerRoot;
+std::string LOOLWSD::ServiceRoot;
std::string LOOLWSD::LOKitVersion;
std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
@@ -695,6 +697,7 @@ void LOOLWSD::initialize(Application& self)
{ "loleaflet_html", "loleaflet.html" },
{ "loleaflet_logging", "false" },
{ "net.proto", "all" },
+ { "net.service_root", "" },
{ "num_prespawn_children", "1" },
{ "per_document.autosave_duration_secs", "300" },
{ "per_document.idle_timeout_secs", "3600" },
@@ -870,6 +873,11 @@ void LOOLWSD::initialize(Application& self)
LOG_WRN("Invalid protocol: " << proto);
}
+ // Prefix for the loolwsd pages; should not end with a '/'
+ ServiceRoot = getPathFromConfig("net.service_root");
+ while (ServiceRoot.length() > 0 && ServiceRoot[ServiceRoot.length() - 1] == '/')
+ ServiceRoot.pop_back();
+
#if ENABLE_SSL
LOOLWSD::SSLEnabled.set(getConfigValue<bool>(conf, "ssl.enable", true));
#else
@@ -1802,6 +1810,13 @@ private:
try
{
+ // Check and remove the ServiceRoot from the request.getURI()
+ if (!Util::startsWith(request.getURI(), LOOLWSD::ServiceRoot))
+ throw BadRequestException("The request does not start with prefix: " + LOOLWSD::ServiceRoot);
+
+ std::string requestURIString(request.getURI().substr(LOOLWSD::ServiceRoot.length()));
+ request.setURI(requestURIString);
+
// Routing
Poco::URI requestUri(request.getURI());
std::vector<std::string> reqPathSegs;
@@ -2432,6 +2447,7 @@ private:
const std::string loleafletHtml = config.getString("loleaflet_html", "loleaflet.html");
const std::string uriValue = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "https://" : "http://")
+ std::string("%SERVER_HOST%")
+ + LOOLWSD::ServiceRoot
+ "/loleaflet/" LOOLWSD_VERSION_HASH "/" + loleafletHtml + '?';
InputSource inputSrc(discoveryPath);
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 536f8d051..b2014d4f3 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -57,6 +57,7 @@ public:
static std::string ChildRoot;
static std::string ServerName;
static std::string FileServerRoot;
+ static std::string ServiceRoot; ///< There are installations that need prefixing every page with some path.
static std::string LOKitVersion;
static std::string LogLevel;
static bool AnonymizeFilenames;
More information about the Libreoffice-commits
mailing list