[Libreoffice-commits] online.git: loolwsd/Storage.cpp loolwsd/Storage.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Apr 17 15:25:16 UTC 2016
loolwsd/Storage.cpp | 19 ++++++++++++++-----
loolwsd/Storage.hpp | 3 ++-
2 files changed, 16 insertions(+), 6 deletions(-)
New commits:
commit b50a7d507c6ffa04767c3694f667f66089cef0d5
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Apr 16 18:12:10 2016 -0400
loolwsd: wopi trusted hosts are stored in set to warn about conflicting config
Change-Id: If27e173ffee753e655057d8516f4f3b3ecda5d3b
Reviewed-on: https://gerrit.libreoffice.org/24159
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index a3b68e2..67ed5ec 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -34,7 +34,7 @@
///////////////////
bool StorageBase::_filesystemEnabled;
bool StorageBase::_wopiEnabled;
-std::vector<std::string> StorageBase::_wopiHosts;
+std::set<std::string> StorageBase::_wopiHosts;
std::string StorageBase::getLocalRootPath() const
{
@@ -70,13 +70,22 @@ void StorageBase::initialize()
for (size_t i = 0; ; ++i)
{
const std::string path = "storage.wopi.host[" + std::to_string(i) + "]";
- if (app.config().getBool(path + "[@allow]", false))
+ const auto host = app.config().getString(path, "");
+ if (!host.empty())
{
- const auto host = app.config().getString(path, "");
- if (!host.empty())
+ if (app.config().getBool(path + "[@allow]", false))
{
Log::info("Adding trusted WOPI host: [" + host + "].");
- _wopiHosts.push_back(host);
+ _wopiHosts.insert(host);
+ }
+ else
+ {
+ if (_wopiHosts.find(host) != _wopiHosts.end())
+ {
+ Log::warn("Configuration of WOPI trusted hosts contains conflicting duplicates.");
+ }
+
+ _wopiHosts.erase(host);
}
}
else if (!app.config().has(path))
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index 9855bbb..7114269 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -12,6 +12,7 @@
#define INCLUDED_STORAGE_HPP
#include <string>
+#include <set>
#include <Poco/Util/Application.h>
#include <Poco/URI.h>
@@ -87,7 +88,7 @@ protected:
static bool _filesystemEnabled;
static bool _wopiEnabled;
/// Allowed/trusted WOPI hosts, if any and if WOPI is enabled.
- static std::vector<std::string> _wopiHosts;
+ static std::set<std::string> _wopiHosts;
};
/// Trivial implementation of local storage that does not need do anything.
More information about the Libreoffice-commits
mailing list