[Libreoffice-commits] online.git: 2 commits - wsd/ClientSession.cpp wsd/ClientSession.hpp
Pranav Kant
pranavk at collabora.co.uk
Mon Dec 5 15:19:06 UTC 2016
wsd/ClientSession.cpp | 27 ++++++++++++++++++++++++---
wsd/ClientSession.hpp | 4 ++++
2 files changed, 28 insertions(+), 3 deletions(-)
New commits:
commit c8b1b584779dfbf4d53ffd38240336a62b06323e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Dec 5 17:50:22 2016 +0530
wsd: Allow executing search in readonly mode
Change-Id: Ie0c2721e4f932a08dfefae742f9f3c934514fde6
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index d9b49bf..0bd20fc 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -399,6 +399,13 @@ bool ClientSession::filterMessage(const std::string& message) const
{
allowed = true;
}
+ else if (tokens[0] == "uno")
+ {
+ if (tokens[1] == ".uno:ExecuteSearch")
+ {
+ allowed = true;
+ }
+ }
}
return allowed;
commit 8357a2bceefc2e66ec27deb62c387dd612fc89f1
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Dec 5 17:48:33 2016 +0530
wsd: readonly message filtering in separate function
Change-Id: I1c02be876aa4cf2a878082b593de3c83e45e15b3
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 0d86109..d9b49bf 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -213,9 +213,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
}
else
{
- // Allow 'downloadas' for all kinds of views
- if ( (isReadOnly()) && tokens[0] != "downloadas" &&
- tokens[0] != "userinactive" && tokens[0] != "useractive")
+ if (!filterMessage(firstLine))
{
const std::string dummyFrame = "dummymsg";
return forwardToChild(dummyFrame, docBroker);
@@ -390,6 +388,22 @@ bool ClientSession::forwardToChild(const std::string& message,
return docBroker->forwardToChild(getId(), message);
}
+bool ClientSession::filterMessage(const std::string& message) const
+{
+ bool allowed = true;
+ StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+ if (isReadOnly())
+ {
+ allowed = false;
+ if (tokens[0] == "downloadas" || tokens[0] == "userinactive" || tokens[0] == "useractive")
+ {
+ allowed = true;
+ }
+ }
+
+ return allowed;
+}
+
void ClientSession::setReadOnly()
{
_isReadOnly = true;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index bf484f4..3703593 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -87,6 +87,10 @@ private:
bool forwardToChild(const std::string& message,
const std::shared_ptr<DocumentBroker>& docBroker);
+ /// Returns true if given message from the client should be allowed or not
+ /// Eg. in readonly mode only few messages should be allowed
+ bool filterMessage(const std::string& msg) const;
+
private:
std::weak_ptr<DocumentBroker> _docBroker;
More information about the Libreoffice-commits
mailing list