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

Pranav Kant pranavk at collabora.com
Tue Apr 19 11:08:42 UTC 2016


 loleaflet/src/admin/AdminSocketOverview.js |    4 ++--
 loolwsd/AdminModel.cpp                     |   10 +++++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 79b21598d589370408987bc058db9ebf8a1034c8
Author: Pranav Kant <pranavk at collabora.com>
Date:   Tue Apr 19 16:37:12 2016 +0530

    admin console: Handle spaces in filenames
    
    Change-Id: Id63189e5a58e023669304438784d30c6ec48a1c2

diff --git a/loleaflet/src/admin/AdminSocketOverview.js b/loleaflet/src/admin/AdminSocketOverview.js
index a930415..ed1d0b0 100644
--- a/loleaflet/src/admin/AdminSocketOverview.js
+++ b/loleaflet/src/admin/AdminSocketOverview.js
@@ -90,7 +90,7 @@ var AdminSocketOverview = AdminSocketBase.extend({
 				}
 				docProps = documents[i].trim().split(' ');
 				sPid = docProps[0];
-				sName = docProps[1];
+				sName = decodeURI(docProps[1]);
 				sViews = docProps[2];
 				sMem = docProps[3];
 				sDocTime = docProps[4];
@@ -129,7 +129,7 @@ var AdminSocketOverview = AdminSocketBase.extend({
 			textMsg = textMsg.substring('adddoc'.length);
 			docProps = textMsg.trim().split(' ');
 			sPid = docProps[0];
-			sName = docProps[1];
+			sName = decodeURI(docProps[1]);
 			// docProps[2] == sessionid
 			sMem = docProps[3];
 
diff --git a/loolwsd/AdminModel.cpp b/loolwsd/AdminModel.cpp
index d9f10a0..fde6c2e 100644
--- a/loolwsd/AdminModel.cpp
+++ b/loolwsd/AdminModel.cpp
@@ -15,6 +15,7 @@
 #include <Poco/Net/WebSocket.h>
 #include <Poco/Process.h>
 #include <Poco/StringTokenizer.h>
+#include <Poco/URI.h>
 
 #include "AdminModel.hpp"
 #include "Unit.hpp"
@@ -254,9 +255,11 @@ void AdminModel::addDocument(const std::string& docKey, Poco::Process::PID pid,
     // Notify the subscribers
     unsigned memUsage = Util::getMemoryUsage(pid);
     std::ostringstream oss;
+    std::string encodedFilename;
+    Poco::URI::encode(filename, " ", encodedFilename);
     oss << "adddoc "
         << pid << " "
-        << filename << " "
+        << encodedFilename << " "
         << sessionId << " "
         << std::to_string(memUsage);
     Log::info("Message to admin console: " + oss.str());
@@ -351,14 +354,15 @@ std::string AdminModel::getDocuments()
             continue;
 
         std::string sPid = std::to_string(it.second.getPid());
-        // TODO: URI encode the filename
         std::string sFilename = it.second.getFilename();
         std::string sViews = std::to_string(it.second.getActiveViews());
         std::string sMem = std::to_string(Util::getMemoryUsage(it.second.getPid()));
         std::string sElapsed = std::to_string(it.second.getElapsedTime());
 
+        std::string encodedFilename;
+        Poco::URI::encode(sFilename, " ", encodedFilename);
         oss << sPid << " "
-            << sFilename << " "
+            << encodedFilename << " "
             << sViews << " "
             << sMem << " "
             << sElapsed << " \n ";


More information about the Libreoffice-commits mailing list