[Libreoffice-commits] online.git: 2 commits - loleaflet/js wsd/ClientSession.cpp wsd/FileServer.cpp wsd/LOOLWSD.cpp

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 20 16:24:22 UTC 2019


 loleaflet/js/global.js |   25 +++++++++++++++++++++++++
 wsd/ClientSession.cpp  |    6 ++++++
 wsd/FileServer.cpp     |   19 +++++++++++++++++--
 wsd/LOOLWSD.cpp        |    2 --
 4 files changed, 48 insertions(+), 4 deletions(-)

New commits:
commit 3c1a130004845c99a159d634eb79474ff3c8d353
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Aug 20 12:21:25 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Aug 20 18:24:15 2019 +0200

    wsd: fix build, with argument "--disable-ssl"
    
    wsd/LOOLWSD.cpp:1034:14: error: ‘SSLEnabled’ is not a member of ‘LOOLWSD’
    wsd/LOOLWSD.cpp:1049:14: error: ‘SSLTermination’ is not a member of ‘LOOLWSD’
    
    Change-Id: I3e81431ef56f46a844733b797b4c443a77afeb6e
    Reviewed-on: https://gerrit.libreoffice.org/77850
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e0518479d..7fa2072e7 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1030,7 +1030,6 @@ void LOOLWSD::initialize(Application& self)
 
 #if ENABLE_SSL
     LOOLWSD::SSLEnabled.set(getConfigValue<bool>(conf, "ssl.enable", true));
-#else
     LOOLWSD::SSLEnabled.set(false);
 #endif
 
@@ -1045,7 +1044,6 @@ void LOOLWSD::initialize(Application& self)
 
 #if ENABLE_SSL
     LOOLWSD::SSLTermination.set(getConfigValue<bool>(conf, "ssl.termination", true));
-#else
     LOOLWSD::SSLTermination.set(false);
 #endif
 
commit 2872bc7be91aabb1bcecbe5f8c761e917115f43d
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Jul 1 20:25:10 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Aug 20 18:24:04 2019 +0200

    post logs JavaScript runtime errors to the loolwsd server
    
    Change-Id: Ic8ccff52d2f051ea6d31b6d2bfe08fc08ea4d8c2
    Reviewed-on: https://gerrit.libreoffice.org/77849
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index c1d6b9f9e..a8e5eb8f5 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -36,6 +36,31 @@
 		for (var i = 0; i < methods.length; i++) {
 			console[methods[i]] = function() {};
 		}
+	} else {
+		window.onerror = function (msg, src, row, col, err) {
+			var data = {
+				userAgent: navigator.userAgent.toLowerCase(),
+				vendor: navigator.vendor.toLowerCase(),
+				message: msg,
+				source: src,
+				line: row,
+				column: col
+			}, desc = err.message || {}, stack = err.stack || {};
+			var log = 'jserror ' + JSON.stringify(data, null, 2) + '\n' + desc + '\n' + stack + '\n';
+			if (global.socket && (global.socket instanceof WebSocket) && global.socket.readyState === 1) {
+				global.socket.send(log);
+			} else if (global.socket && (global.socket instanceof global.L.Socket) && global.socket.connected()) {
+				global.socket.sendMessage(log);
+			} else {
+				var req = new XMLHttpRequest();
+				var url = global.location.protocol + '//' + global.location.host + global.location.pathname.match(/.*\//) + 'logging.html';
+				req.open('POST', url, true);
+				req.setRequestHeader('Content-type','application/json; charset=utf-8');
+				req.send(log);
+			}
+
+			return false;
+		}
 	}
 
 	// fix jquery-ui
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 56f2a3443..00ca2d506 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -361,6 +361,12 @@ bool ClientSession::_handleInput(const char *buffer, int length)
 
         return true;
     }
+
+    if (tokens[0] == "jserror")
+    {
+        LOG_ERR(std::string(buffer, length));
+        return true;
+    }
     else if (tokens[0] == "load")
     {
         if (getDocURL() != "")
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index f51c67f6c..bfde038c9 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -284,13 +284,28 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
         std::vector<std::string> requestSegments;
         requestUri.getPathSegments(requestSegments);
         const std::string relPath = getRequestPathname(request);
+        const std::string endPoint = requestSegments[requestSegments.size() - 1];
+        const auto& config = Application::instance().config();
+
+        if (request.getMethod() == HTTPRequest::HTTP_POST && endPoint == "logging.html")
+        {
+            const std::string loleafletLogging = config.getString("loleaflet_logging", "false");
+            if (loleafletLogging != "false")
+            {
+                LOG_ERR(message.rdbuf());
+
+                std::ostringstream oss;
+                response.write(oss);
+                socket->send(oss.str());
+                return;
+            }
+        }
+
         // Is this a file we read at startup - if not; its not for serving.
         if (requestSegments.size() < 1 || FileHash.find(relPath) == FileHash.end())
             throw Poco::FileNotFoundException("Invalid URI request: [" + requestUri.toString() + "].");
 
-        const auto& config = Application::instance().config();
         const std::string loleafletHtml = config.getString("loleaflet_html", "loleaflet.html");
-        const std::string endPoint = requestSegments[requestSegments.size() - 1];
         if (endPoint == loleafletHtml || endPoint == "clipboard.html")
         {
             preprocessFile(request, message, socket, endPoint);


More information about the Libreoffice-commits mailing list