diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-02-28 10:50:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-28 16:07:56 +0100 |
commit | b8bd1990aaa1b063ca21b78ffec629b5d5ae7697 (patch) | |
tree | 15d21403ca3712252f2927d4826be0cad5b46461 | |
parent | 133dee2980538ded58dfe82b16b14ba80fe35a85 (diff) |
Rework LOOLProtocol::tokenize() to return a StringVector object
The bulk of this commit just changes std::vector<std::string> to
StringVector when we deal with tokens from a websocket message.
The less boring part of it is the new StringVector class, which is a
wrapper around std::vector<std::string>, and provides the same API,
except that operator[] returns a string, not a string&, and this allows
returning an empty string in case that prevents reading past the end of
the underlying array.
This means in case client code forgets to check size() before invoking
operator[], we don't crash. (See the ~3 previous commits which fixed
such crashes.)
Later the ctor could be changed to take a single underlying string to
avoid lots of tiny allocations, that's not yet done in this commit.
Change-Id: I8a6082143a8ac0b65824f574b32104d7889c184f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89687
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
46 files changed, 289 insertions, 183 deletions
diff --git a/Makefile.am b/Makefile.am index 1ee125b1f..bf5725b92 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,6 +92,7 @@ shared_sources = common/FileUtil.cpp \ common/IoUtil.cpp \ common/Log.cpp \ common/Protocol.cpp \ + common/StringVector.cpp \ common/Session.cpp \ common/Seccomp.cpp \ common/MessageQueue.cpp \ @@ -138,12 +139,14 @@ endif connect_SOURCES = tools/Connect.cpp \ common/Log.cpp \ common/Protocol.cpp \ + common/StringVector.cpp \ common/Util.cpp lokitclient_SOURCES = common/IoUtil.cpp \ common/Log.cpp \ tools/KitClient.cpp \ common/Protocol.cpp \ + common/StringVector.cpp \ common/Util.cpp loolforkit_sources = kit/ChildSession.cpp \ @@ -170,6 +173,7 @@ clientsession_fuzzer_LDFLAGS = -fsanitize=fuzzer $(AM_LDFLAGS) clientnb_SOURCES = net/clientnb.cpp \ common/Log.cpp \ + common/StringVector.cpp \ common/Util.cpp loolmount_SOURCES = tools/mount.cpp @@ -181,12 +185,14 @@ loolconvert_SOURCES = tools/Tool.cpp loolstress_CPPFLAGS = -DTDOC=\"$(abs_top_srcdir)/test/data\" ${include_paths} loolstress_SOURCES = tools/Stress.cpp \ common/Protocol.cpp \ + common/StringVector.cpp \ common/Log.cpp \ common/Util.cpp loolconfig_SOURCES = tools/Config.cpp \ common/Crypto.cpp \ common/Log.cpp \ + common/StringVector.cpp \ common/Util.cpp loolsocketdump_SOURCES = tools/WebSocketDump.cpp \ @@ -218,6 +224,7 @@ shared_headers = common/Common.hpp \ common/Log.hpp \ common/LOOLWebSocket.hpp \ common/Protocol.hpp \ + common/StringVector.hpp \ common/Seccomp.hpp \ common/Session.hpp \ common/Unit.hpp \ diff --git a/android/lib/src/main/cpp/CMakeLists.txt.in b/android/lib/src/main/cpp/CMakeLists.txt.in index 29abef905..7b5b5323f 100644 --- a/android/lib/src/main/cpp/CMakeLists.txt.in +++ b/android/lib/src/main/cpp/CMakeLists.txt.in @@ -6,6 +6,7 @@ add_library(androidapp SHARED ../../../../../common/Log.cpp ../../../../../common/MessageQueue.cpp ../../../../../common/Protocol.cpp + ../../../../../common/StringVector.cpp ../../../../../common/Session.cpp ../../../../../common/SigUtil.cpp ../../../../../common/SpookyV2.cpp diff --git a/common/Message.hpp b/common/Message.hpp index 3fdbc5d36..9320037c7 100644 --- a/common/Message.hpp +++ b/common/Message.hpp @@ -80,11 +80,11 @@ public: size_t size() const { return _data.size(); } const std::vector<char>& data() const { return _data; } - const std::vector<std::string>& tokens() const { return _tokens; } + const StringVector& tokens() const { return _tokens; } const std::string& forwardToken() const { return _forwardToken; } - const std::string& firstToken() const { return _tokens[0]; } + std::string firstToken() const { return _tokens[0]; } const std::string& firstLine() const { return _firstLine; } - const std::string& operator[](size_t index) const { return _tokens[index]; } + std::string operator[](size_t index) const { return _tokens[index]; } bool getTokenInteger(const std::string& name, int& value) { @@ -177,7 +177,7 @@ private: private: const std::string _forwardToken; std::vector<char> _data; - const std::vector<std::string> _tokens; + const StringVector _tokens; const std::string _id; const std::string _firstLine; const std::string _abbr; diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp index dd8ea33b3..84987b278 100644 --- a/common/MessageQueue.cpp +++ b/common/MessageQueue.cpp @@ -30,7 +30,7 @@ void TileQueue::put_impl(const Payload& value) { LOG_TRC("Processing [" << LOOLProtocol::getAbbreviatedMessage(msg) << "]. Before canceltiles have " << getQueue().size() << " in queue."); const std::string seqs = msg.substr(12); - std::vector<std::string> tokens(LOOLProtocol::tokenize(seqs, ',')); + StringVector tokens(LOOLProtocol::tokenize(seqs, ',')); getQueue().erase(std::remove_if(getQueue().begin(), getQueue().end(), [&tokens](const Payload& v) { @@ -126,7 +126,7 @@ void TileQueue::removeTileDuplicate(const std::string& tileMsg) namespace { /// Read the viewId from the tokens. -std::string extractViewId(const std::string& origMsg, const std::vector<std::string>& tokens) +std::string extractViewId(const std::string& origMsg, const StringVector& tokens) { size_t nonJson = tokens[0].size() + tokens[1].size() + tokens[2].size() + 3; // including spaces std::string jsonString(origMsg.data() + nonJson, origMsg.size() - nonJson); @@ -151,7 +151,7 @@ std::string extractUnoCommand(const std::string& command) } /// Extract rectangle from the invalidation callback -bool extractRectangle(const std::vector<std::string>& tokens, int& x, int& y, int& w, int& h, int& part) +bool extractRectangle(const StringVector& tokens, int& x, int& y, int& w, int& h, int& part) { x = 0; y = 0; @@ -186,7 +186,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg) { assert(LOOLProtocol::matchPrefix("callback", callbackMsg, /*ignoreWhitespace*/ true)); - std::vector<std::string> tokens = LOOLProtocol::tokenize(callbackMsg); + StringVector tokens = LOOLProtocol::tokenize(callbackMsg); if (tokens.size() < 3) return std::string(); @@ -211,7 +211,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg) { auto& it = getQueue()[i]; - std::vector<std::string> queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); + StringVector queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); if (queuedTokens.size() < 3) { ++i; @@ -316,7 +316,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg) { auto& it = getQueue()[i]; - std::vector<std::string> queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); + StringVector queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); if (queuedTokens.size() < 4) continue; @@ -362,7 +362,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg) if (!LOOLProtocol::matchPrefix("callback", it)) continue; - std::vector<std::string> queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); + StringVector queuedTokens = LOOLProtocol::tokenize(it.data(), it.size()); if (queuedTokens.size() < 3) continue; diff --git a/common/Protocol.cpp b/common/Protocol.cpp index 4d8f51c50..7e5208774 100644 --- a/common/Protocol.cpp +++ b/common/Protocol.cpp @@ -27,12 +27,12 @@ namespace LOOLProtocol int minor = -1; std::string patch; - std::vector<std::string> firstTokens(tokenize(version, '.')); + StringVector firstTokens(tokenize(version, '.')); if (firstTokens.size() > 0) { major = std::stoi(firstTokens[0]); - std::vector<std::string> secondTokens; + StringVector secondTokens; if (firstTokens.size() > 1) { secondTokens = tokenize(firstTokens[1], '-'); @@ -170,7 +170,7 @@ namespace LOOLProtocol return false; } - bool getTokenInteger(const std::vector<std::string>& tokens, const std::string& name, int& value) + bool getTokenInteger(const StringVector& tokens, const std::string& name, int& value) { for (size_t i = 0; i < tokens.size(); i++) { @@ -180,7 +180,7 @@ namespace LOOLProtocol return false; } - bool getTokenKeyword(const std::vector<std::string>& tokens, const std::string& name, const std::map<std::string, int>& map, int& value) + bool getTokenKeyword(const StringVector& tokens, const std::string& name, const std::map<std::string, int>& map, int& value) { for (size_t i = 0; i < tokens.size(); i++) { diff --git a/common/Protocol.hpp b/common/Protocol.hpp index e1a5d426e..787be3706 100644 --- a/common/Protocol.hpp +++ b/common/Protocol.hpp @@ -75,11 +75,11 @@ namespace LOOLProtocol bool getTokenString(const std::string& token, const std::string& name, std::string& value); bool getTokenKeyword(const std::string& token, const std::string& name, const std::map<std::string, int>& map, int& value); - bool getTokenKeyword(const std::vector<std::string>& tokens, const std::string& name, const std::map<std::string, int>& map, int& value); + bool getTokenKeyword(const StringVector& tokens, const std::string& name, const std::map<std::string, int>& map, int& value); - bool getTokenInteger(const std::vector<std::string>& tokens, const std::string& name, int& value); + bool getTokenInteger(const StringVector& tokens, const std::string& name, int& value); - inline bool getTokenString(const std::vector<std::string>& tokens, + inline bool getTokenString(const StringVector& tokens, const std::string& name, std::string& value) { @@ -99,12 +99,12 @@ namespace LOOLProtocol /// Tokenize space-delimited values until we hit new-line or the end. inline - std::vector<std::string> tokenize(const char* data, const size_t size, const char delimiter = ' ') + StringVector tokenize(const char* data, const size_t size, const char delimiter = ' ') { std::vector<std::string> tokens; if (size == 0 || data == nullptr) { - return tokens; + return StringVector(tokens); } tokens.reserve(8); @@ -132,11 +132,11 @@ namespace LOOLProtocol tokens.emplace_back(start, end); } - return tokens; + return StringVector(tokens); } inline - std::vector<std::string> tokenize(const std::string& s, const char delimiter = ' ') + StringVector tokenize(const std::string& s, const char delimiter = ' ') { return tokenize(s.data(), s.size(), delimiter); } diff --git a/common/Seccomp.cpp b/common/Seccomp.cpp index c22937f9f..116056892 100644 --- a/common/Seccomp.cpp +++ b/common/Seccomp.cpp @@ -269,7 +269,7 @@ void setRLimit(rlim_t confLim, int resource, const std::string &resourceText, co LOG_INF("Ignored setting " << resourceText << " to " << limTextWithUnit << "."); } -bool handleSetrlimitCommand(const std::vector<std::string>& tokens) +bool handleSetrlimitCommand(const StringVector& tokens) { if (tokens.size() == 3 && tokens[0] == "setconfig") { diff --git a/common/Seccomp.hpp b/common/Seccomp.hpp index 5a09de772..400745bfa 100644 --- a/common/Seccomp.hpp +++ b/common/Seccomp.hpp @@ -9,8 +9,7 @@ #ifndef INCLUDED_SECCOMP_HPP #define INCLUDED_SECCOMP_HPP -#include <string> -#include <vector> +#include <Protocol.hpp> namespace Seccomp { enum Type { KIT, WSD }; @@ -22,7 +21,7 @@ namespace Seccomp { namespace Rlimit { /// Handles setconfig command with limit_... subcommands. /// Returns true iff it handled the command, regardless of success/failure. - bool handleSetrlimitCommand(const std::vector<std::string>& tokens); + bool handleSetrlimitCommand(const StringVector& tokens); }; #endif diff --git a/common/Session.cpp b/common/Session.cpp index 2a51b0e89..815fd5391 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -75,7 +75,7 @@ bool Session::sendBinaryFrame(const char *buffer, int length) return sendMessage(buffer, length, WSOpCode::Binary) >= length; } -void Session::parseDocOptions(const std::vector<std::string>& tokens, int& part, std::string& timestamp, std::string& doctemplate) +void Session::parseDocOptions(const StringVector& tokens, int& part, std::string& timestamp, std::string& doctemplate) { // First token is the "load" command itself. size_t offset = 1; diff --git a/common/Session.hpp b/common/Session.hpp index aa585a559..8171fef64 100644 --- a/common/Session.hpp +++ b/common/Session.hpp @@ -168,7 +168,7 @@ protected: /// Parses the options of the "load" command, /// shared between MasterProcessSession::loadDocument() and ChildProcessSession::loadDocument(). - void parseDocOptions(const std::vector<std::string>& tokens, int& part, std::string& timestamp, std::string& doctemplate); + void parseDocOptions(const StringVector& tokens, int& part, std::string& timestamp, std::string& doctemplate); void updateLastActivityTime() { diff --git a/common/StringVector.cpp b/common/StringVector.cpp new file mode 100644 index 000000000..a4bf78109 --- /dev/null +++ b/common/StringVector.cpp @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "StringVector.hpp" + +StringVector::StringVector() = default; + +StringVector::StringVector(const std::vector<std::string>& vector) { _vector = vector; } + +std::string StringVector::operator[](size_t index) const +{ + if (index >= _vector.size()) + { + return std::string(); + } + + return _vector[index]; +} + +size_t StringVector::size() const { return _vector.size(); } + +bool StringVector::empty() const { return _vector.empty(); } + +std::vector<std::string>::const_iterator StringVector::begin() const { return _vector.begin(); } + +std::vector<std::string>::iterator StringVector::begin() { return _vector.begin(); } + +std::vector<std::string>::const_iterator StringVector::end() const { return _vector.end(); } + +std::vector<std::string>::iterator StringVector::end() { return _vector.end(); } + +std::vector<std::string>::iterator StringVector::erase(std::vector<std::string>::const_iterator it) +{ + return _vector.erase(it); +} + +void StringVector::push_back(const std::string& string) { _vector.push_back(string); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/StringVector.hpp b/common/StringVector.hpp new file mode 100644 index 000000000..346bfabff --- /dev/null +++ b/common/StringVector.hpp @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_STRINGVECTOR_HPP +#define INCLUDED_STRINGVECTOR_HPP + +#include <string> +#include <vector> + +/** + * Safe wrapper around an std::vector<std::string>. Gives you an empty string if you would read past + * the ends of the vector. + */ +class StringVector +{ + std::vector<std::string> _vector; + +public: + explicit StringVector(); + + explicit StringVector(const std::vector<std::string>& vector); + + /// Unlike std::vector, gives an empty string if index is unexpected. + std::string operator[](size_t index) const; + + size_t size() const; + + bool empty() const; + + std::vector<std::string>::const_iterator begin() const; + + std::vector<std::string>::iterator begin(); + + std::vector<std::string>::const_iterator end() const; + + std::vector<std::string>::iterator end(); + + std::vector<std::string>::iterator erase(std::vector<std::string>::const_iterator it); + + void push_back(const std::string& string); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/Util.cpp b/common/Util.cpp index f9df08f2f..9a2273eaf 100644 --- a/common/Util.cpp +++ b/common/Util.cpp @@ -245,7 +245,7 @@ namespace Util } } - int spawnProcess(const std::string &cmd, const std::vector<std::string> &args, const std::vector<int>* fdsToKeep, int *stdInput) + int spawnProcess(const std::string &cmd, const StringVector &args, const std::vector<int>* fdsToKeep, int *stdInput) { int pipeFds[2] = { -1, -1 }; if (stdInput) diff --git a/common/Util.hpp b/common/Util.hpp index 991b548ef..52043692f 100644 --- a/common/Util.hpp +++ b/common/Util.hpp @@ -38,6 +38,8 @@ #define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <StringVector.hpp> + namespace Util { namespace rng @@ -68,7 +70,7 @@ namespace Util /// Spawn a process if stdInput is non-NULL it contains a writable descriptor /// to send data to the child. - int spawnProcess(const std::string &cmd, const std::vector<std::string> &args, + int spawnProcess(const std::string &cmd, const StringVector &args, const std::vector<int>* fdsToKeep = nullptr, int *stdInput = nullptr); #endif diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 83acd082f..13bc1d8e4 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -106,7 +106,7 @@ bool ChildSession::_handleInput(const char *buffer, int length) { LOG_TRC(getName() << ": handling [" << getAbbreviatedMessage(buffer, length) << "]."); const std::string firstLine = getFirstLine(buffer, length); - const std::vector<std::string> tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size()); + const StringVector tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size()); if (LOOLProtocol::tokenIndicatesUserInteraction(tokens[0])) { @@ -368,7 +368,7 @@ bool ChildSession::_handleInput(const char *buffer, int length) std::vector<std::string> newTokens; newTokens.push_back(tokens[0]); newTokens.push_back(firstLine.substr(4)); // Copy the remaining part. - return unoCommand(buffer, length, newTokens); + return unoCommand(buffer, length, StringVector(newTokens)); } return unoCommand(buffer, length, tokens); } @@ -467,7 +467,7 @@ std::string getMimeFromFileType(const std::string & fileType) return std::string(); } -bool ChildSession::uploadSignedDocument(const char* buffer, int length, const std::vector<std::string>& /*tokens*/) +bool ChildSession::uploadSignedDocument(const char* buffer, int length, const StringVector& /*tokens*/) { std::string filename; std::string wopiUrl; @@ -578,7 +578,7 @@ bool ChildSession::uploadSignedDocument(const char* buffer, int length, const st #endif -bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const StringVector& tokens) { int part = -1; if (tokens.size() < 2) @@ -660,7 +660,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const s return true; } -bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string font, text, decodedFont, decodedChar; bool bSuccess; @@ -774,7 +774,7 @@ void insertUserNames(const std::map<int, UserInfo>& viewInfo, std::string& json) } -bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { bool success; char* values; @@ -813,7 +813,7 @@ bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, cons return success; } -bool ChildSession::clientZoom(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::clientZoom(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight; @@ -833,7 +833,7 @@ bool ChildSession::clientZoom(const char* /*buffer*/, int /*length*/, const std: return true; } -bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int x; int y; @@ -856,7 +856,7 @@ bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, con return true; } -bool ChildSession::outlineState(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::outlineState(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string type, state; int level, index; @@ -882,7 +882,7 @@ bool ChildSession::outlineState(const char* /*buffer*/, int /*length*/, const st return true; } -bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string name, id, format, filterOptions; @@ -966,7 +966,7 @@ std::string ChildSession::getTextSelectionInternal(const std::string& mimeType) return str; } -bool ChildSession::getTextSelection(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::getTextSelection(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string mimeType; @@ -1006,7 +1006,7 @@ bool ChildSession::getTextSelection(const char* /*buffer*/, int /*length*/, cons return true; } -bool ChildSession::getClipboard(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::getClipboard(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { const char **pMimeTypes = nullptr; // fetch all for now. const char *pOneType[2]; @@ -1068,7 +1068,7 @@ bool ChildSession::getClipboard(const char* /*buffer*/, int /*length*/, const st return true; } -bool ChildSession::setClipboard(const char* buffer, int length, const std::vector<std::string>& /* tokens */) +bool ChildSession::setClipboard(const char* buffer, int length, const StringVector& /* tokens */) { try { ClipboardData data; @@ -1107,7 +1107,7 @@ bool ChildSession::setClipboard(const char* buffer, int length, const std::vecto return false; } -bool ChildSession::paste(const char* buffer, int length, const std::vector<std::string>& tokens) +bool ChildSession::paste(const char* buffer, int length, const StringVector& tokens) { std::string mimeType; if (tokens.size() < 2 || !getTokenString(tokens[1], "mimetype", mimeType) || @@ -1151,7 +1151,7 @@ bool ChildSession::paste(const char* buffer, int length, const std::vector<std:: return true; } -bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string name, type; @@ -1213,7 +1213,7 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const std: } bool ChildSession::extTextInputEvent(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens) + const StringVector& tokens) { int id, type; std::string text; @@ -1239,7 +1239,7 @@ bool ChildSession::extTextInputEvent(const char* /*buffer*/, int /*length*/, } bool ChildSession::keyEvent(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens, + const StringVector& tokens, const LokEventTargetEnum target) { int type, charcode, keycode; @@ -1296,7 +1296,7 @@ bool ChildSession::keyEvent(const char* /*buffer*/, int /*length*/, } bool ChildSession::gestureEvent(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens) + const StringVector& tokens) { bool success = true; @@ -1333,7 +1333,7 @@ bool ChildSession::gestureEvent(const char* /*buffer*/, int /*length*/, } bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens, + const StringVector& tokens, const LokEventTargetEnum target) { int type, x, y, count; @@ -1401,7 +1401,7 @@ bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/, return true; } -bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { if (tokens.size() <= 2) { @@ -1418,7 +1418,7 @@ bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const std return true; } -bool ChildSession::completeFunction(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::completeFunction(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int index; @@ -1435,7 +1435,7 @@ bool ChildSession::completeFunction(const char* /*buffer*/, int /*length*/, cons return true; } -bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { if (tokens.size() <= 1) { @@ -1476,7 +1476,7 @@ bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, const std: } bool ChildSession::selectText(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens, + const StringVector& tokens, const LokEventTargetEnum target) { std::string swap; @@ -1528,7 +1528,7 @@ bool ChildSession::selectText(const char* /*buffer*/, int /*length*/, return true; } -bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0); @@ -1539,7 +1539,7 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st if (tokens.size() > 2 && getTokenString(tokens[2], "rectangle", paintRectangle) && paintRectangle != "undefined") { - const std::vector<std::string> rectParts + const StringVector rectParts = LOOLProtocol::tokenize(paintRectangle.c_str(), paintRectangle.length(), ','); if (rectParts.size() == 4) { @@ -1604,7 +1604,7 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st return true; } -bool ChildSession::resizeWindow(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::resizeWindow(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1].c_str(), nullptr, 10) : 0); @@ -1625,7 +1625,7 @@ bool ChildSession::resizeWindow(const char* /*buffer*/, int /*length*/, const st return true; } -bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0); @@ -1686,7 +1686,7 @@ std::string extractPrivateKey(const std::string & privateKey) } -bool ChildSession::signDocumentContent(const char* buffer, int length, const std::vector<std::string>& /*tokens*/) +bool ChildSession::signDocumentContent(const char* buffer, int length, const StringVector& /*tokens*/) { bool bResult = true; @@ -1729,7 +1729,7 @@ bool ChildSession::signDocumentContent(const char* buffer, int length, const std #if !MOBILEAPP -bool ChildSession::exportSignAndUploadDocument(const char* buffer, int length, const std::vector<std::string>& /*tokens*/) +bool ChildSession::exportSignAndUploadDocument(const char* buffer, int length, const StringVector& /*tokens*/) { bool bResult = false; @@ -1892,7 +1892,7 @@ bool ChildSession::exportSignAndUploadDocument(const char* buffer, int length, c #endif -bool ChildSession::askSignatureStatus(const char* buffer, int length, const std::vector<std::string>& /*tokens*/) +bool ChildSession::askSignatureStatus(const char* buffer, int length, const StringVector& /*tokens*/) { bool bResult = true; @@ -1929,7 +1929,7 @@ bool ChildSession::askSignatureStatus(const char* buffer, int length, const std: return true; } -bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int type, x, y; if (tokens.size() != 4 || @@ -1951,7 +1951,7 @@ bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, const s return true; } -bool ChildSession::resetSelection(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::resetSelection(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { if (tokens.size() != 1) { @@ -1966,7 +1966,7 @@ bool ChildSession::resetSelection(const char* /*buffer*/, int /*length*/, const return true; } -bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string wopiFilename, url, format, filterOptions; @@ -2064,7 +2064,7 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const std::vec return true; } -bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int part; if (tokens.size() < 2 || @@ -2084,7 +2084,7 @@ bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, const s return true; } -bool ChildSession::selectClientPart(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::selectClientPart(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int nPart; int nSelect; @@ -2118,7 +2118,7 @@ bool ChildSession::selectClientPart(const char* /*buffer*/, int /*length*/, cons return true; } -bool ChildSession::moveSelectedClientParts(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::moveSelectedClientParts(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int nPosition; if (tokens.size() < 2 || @@ -2147,7 +2147,7 @@ bool ChildSession::moveSelectedClientParts(const char* /*buffer*/, int /*length* return true; // Non-fatal to fail. } -bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { int page; if (tokens.size() < 2 || @@ -2163,7 +2163,7 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const std::ve return true; } -bool ChildSession::renderShapeSelection(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) +bool ChildSession::renderShapeSelection(const char* /*buffer*/, int /*length*/, const StringVector& tokens) { std::string mimeType; if (tokens.size() != 2 || @@ -2198,7 +2198,7 @@ bool ChildSession::renderShapeSelection(const char* /*buffer*/, int /*length*/, } bool ChildSession::removeTextContext(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens) + const StringVector& tokens) { int id, before, after; std::string text; @@ -2333,7 +2333,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) { case LOK_CALLBACK_INVALIDATE_TILES: { - std::vector<std::string> tokens(LOOLProtocol::tokenize(payload, ',')); + StringVector tokens(LOOLProtocol::tokenize(payload, ',')); if (tokens.size() == 5) { int part, x, y, width, height; diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index 8aaa46b54..9bb2b7d0f 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -231,7 +231,7 @@ public: using Session::sendTextFrame; - bool getClipboard(const char* buffer, int length, const std::vector<std::string>& tokens); + bool getClipboard(const char* buffer, int length, const StringVector& tokens); void resetDocManager() { @@ -244,46 +244,46 @@ public: } private: - bool loadDocument(const char* buffer, int length, const std::vector<std::string>& tokens); + bool loadDocument(const char* buffer, int length, const StringVector& tokens); - bool sendFontRendering(const char* buffer, int length, const std::vector<std::string>& tokens); - bool getCommandValues(const char* buffer, int length, const std::vector<std::string>& tokens); + bool sendFontRendering(const char* buffer, int length, const StringVector& tokens); + bool getCommandValues(const char* buffer, int length, const StringVector& tokens); - bool clientZoom(const char* buffer, int length, const std::vector<std::string>& tokens); - bool clientVisibleArea(const char* buffer, int length, const std::vector<std::string>& tokens); - bool outlineState(const char* buffer, int length, const std::vector<std::string>& tokens); - bool downloadAs(const char* buffer, int length, const std::vector<std::string>& tokens); + bool clientZoom(const char* buffer, int length, const StringVector& tokens); + bool clientVisibleArea(const char* buffer, int length, const StringVector& tokens); + bool outlineState(const char* buffer, int length, const StringVector& tokens); + bool downloadAs(const char* buffer, int length, const StringVector& tokens); bool getChildId(); - bool getTextSelection(const char* buffer, int length, const std::vector<std::string>& tokens); - bool setClipboard(const char* buffer, int length, const std::vector<std::string>& tokens); + bool getTextSelection(const char* buffer, int length, const StringVector& tokens); + bool setClipboard(const char* buffer, int length, const StringVector& tokens); std::string getTextSelectionInternal(const std::string& mimeType); - bool paste(const char* buffer, int length, const std::vector<std::string>& tokens); - bool insertFile(const char* buffer, int length, const std::vector<std::string>& tokens); - bool keyEvent(const char* buffer, int length, const std::vector<std::string>& tokens, const LokEventTargetEnum target); - bool extTextInputEvent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens); + bool paste(const char* buffer, int length, const StringVector& tokens); + bool insertFile(const char* buffer, int length, const StringVector& tokens); + bool keyEvent(const char* buffer, int length, const StringVector& tokens, const LokEventTargetEnum target); + bool extTextInputEvent(const char* /*buffer*/, int /*length*/, const StringVector& tokens); bool dialogKeyEvent(const char* buffer, int length, const std::vector<std::string>& tokens); - bool mouseEvent(const char* buffer, int length, const std::vector<std::string>& tokens, const LokEventTargetEnum target); - bool gestureEvent(const char* buffer, int length, const std::vector<std::string>& tokens); - bool dialogEvent(const char* buffer, int length, const std::vector<std::string>& tokens); - bool completeFunction(const char* buffer, int length, const std::vector<std::string>& tokens); - bool unoCommand(const char* buffer, int length, const std::vector<std::string>& tokens); - bool selectText(const char* buffer, int length, const std::vector<std::string>& tokens, const LokEventTargetEnum target); - bool selectGraphic(const char* buffer, int length, const std::vector<std::string>& tokens); - bool renderWindow(const char* buffer, int length, const std::vector<std::string>& tokens); - bool resizeWindow(const char* buffer, int length, const std::vector<std::string>& tokens); - bool resetSelection(const char* buffer, int length, const std::vector<std::string>& tokens); - bool saveAs(const char* buffer, int length, const std::vector<std::string>& tokens); - bool setClientPart(const char* buffer, int length, const std::vector<std::string>& tokens); - bool selectClientPart(const char* buffer, int length, const std::vector<std::string>& tokens); - bool moveSelectedClientParts(const char* buffer, int length, const std::vector<std::string>& tokens); - bool setPage(const char* buffer, int length, const std::vector<std::string>& tokens); - bool sendWindowCommand(const char* buffer, int length, const std::vector<std::string>& tokens); - bool signDocumentContent(const char* buffer, int length, const std::vector<std::string>& tokens); - bool askSignatureStatus(const char* buffer, int length, const std::vector<std::string>& tokens); - bool uploadSignedDocument(const char* buffer, int length, const std::vector<std::string>& tokens); - bool exportSignAndUploadDocument(const char* buffer, int length, const std::vector<std::string>& tokens); - bool renderShapeSelection(const char* buffer, int length, const std::vector<std::string>& tokens); - bool removeTextContext(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens); + bool mouseEvent(const char* buffer, int length, const StringVector& tokens, const LokEventTargetEnum target); + bool gestureEvent(const char* buffer, int length, const StringVector& tokens); + bool dialogEvent(const char* buffer, int length, const StringVector& tokens); + bool completeFunction(const char* buffer, int length, const StringVector& tokens); + bool unoCommand(const char* buffer, int length, const StringVector& tokens); + bool selectText(const char* buffer, int length, const StringVector& tokens, const LokEventTargetEnum target); + bool selectGraphic(const char* buffer, int length, const StringVector& tokens); + bool renderWindow(const char* buffer, int length, const StringVector& tokens); + bool resizeWindow(const char* buffer, int length, const StringVector& tokens); + bool resetSelection(const char* buffer, int length, const StringVector& tokens); + bool saveAs(const char* buffer, int length, const StringVector& tokens); + bool setClientPart(const char* buffer, int length, const StringVector& tokens); + bool selectClientPart(const char* buffer, int length, const StringVector& tokens); + bool moveSelectedClientParts(const char* buffer, int length, const StringVector& tokens); + bool setPage(const char* buffer, int length, const StringVector& tokens); + bool sendWindowCommand(const char* buffer, int length, const StringVector& tokens); + bool signDocumentContent(const char* buffer, int length, const StringVector& tokens); + bool askSignatureStatus(const char* buffer, int length, const StringVector& tokens); + bool uploadSignedDocument(const char* buffer, int length, const StringVector& tokens); + bool exportSignAndUploadDocument(const char* buffer, int length, const StringVector& tokens); + bool renderShapeSelection(const char* buffer, int length, const StringVector& tokens); + bool removeTextContext(const char* /*buffer*/, int /*length*/, const StringVector& tokens); void rememberEventsForInactiveUser(const int type, const std::string& payload); diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index c75f06501..90a7947fd 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -96,7 +96,7 @@ public: LOG_INF("ForKit command: [" << message << "]."); try { - std::vector<std::string> tokens = LOOLProtocol::tokenize(message); + StringVector tokens = LOOLProtocol::tokenize(message); if (tokens.size() == 2 && tokens[0] == "spawn") { const int count = std::stoi(tokens[1]); @@ -441,11 +441,11 @@ int main(int argc, char** argv) { eq = std::strchr(cmd, '='); const std::string rlimits = std::string(eq+1); - std::vector<std::string> tokens = LOOLProtocol::tokenize(rlimits, ';'); + StringVector tokens = LOOLProtocol::tokenize(rlimits, ';'); for (const std::string& cmdLimit : tokens) { const std::pair<std::string, std::string> pair = Util::split(cmdLimit, ':'); - std::vector<std::string> tokensLimit = { "setconfig", pair.first, pair.second }; + StringVector tokensLimit({ "setconfig", pair.first, pair.second }); if (!Rlimit::handleSetrlimitCommand(tokensLimit)) { LOG_ERR("Unknown rlimits command: " << cmdLimit); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 134abf2d6..201628c54 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -880,13 +880,13 @@ public: LOG_INF("setDocumentPassword returned"); } - void renderTile(const std::vector<std::string>& tokens) + void renderTile(const StringVector& tokens) { TileCombined tileCombined(TileDesc::parse(tokens)); renderTiles(tileCombined, false); } - void renderCombinedTiles(const std::vector<std::string>& tokens) + void renderCombinedTiles(const StringVector& tokens) { TileCombined tileCombined = TileCombined::parse(tokens); renderTiles(tileCombined, true); @@ -1242,7 +1242,7 @@ public: if (type == LOK_CALLBACK_CELL_CURSOR) { - std::vector<std::string> tokens(LOOLProtocol::tokenize(payload, ',')); + StringVector tokens(LOOLProtocol::tokenize(payload, ',')); // Payload may be 'EMPTY'. if (tokens.size() == 4) { @@ -1260,7 +1260,7 @@ public: const Poco::Dynamic::Var result = parser.parse(payload); const auto& command = result.extract<Poco::JSON::Object::Ptr>(); std::string rectangle = command->get("rectangle").toString(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(rectangle, ',')); + StringVector tokens(LOOLProtocol::tokenize(rectangle, ',')); // Payload may be 'EMPTY'. if (tokens.size() == 4) { @@ -1281,7 +1281,7 @@ public: targetViewId = command->get("viewId").toString(); std::string part = command->get("part").toString(); std::string text = command->get("rectangle").toString(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(text, ',')); + StringVector tokens(LOOLProtocol::tokenize(text, ',')); // Payload may be 'EMPTY'. if (tokens.size() == 4) { @@ -1872,7 +1872,7 @@ public: LOG_TRC("Kit Recv " << LOOLProtocol::getAbbreviatedMessage(input)); - const std::vector<std::string> tokens = LOOLProtocol::tokenize(input.data(), input.size()); + const StringVector tokens = LOOLProtocol::tokenize(input.data(), input.size()); if (tokens[0] == "eof") { @@ -2101,7 +2101,7 @@ protected: if (UnitKit::get().filterKitMessage(this, message)) return; #endif - std::vector<std::string> tokens = LOOLProtocol::tokenize(message); + StringVector tokens = LOOLProtocol::tokenize(message); Log::StreamLogger logger = Log::debug(); if (logger.enabled()) { diff --git a/test/Makefile.am b/test/Makefile.am index e6588810c..3732c6a4e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -81,6 +81,7 @@ unittest_SOURCES = \ ../common/Session.cpp \ ../common/SigUtil.cpp \ ../common/Unit.cpp \ + ../common/StringVector.cpp \ ../net/Socket.cpp \ ../wsd/Auth.cpp \ ../wsd/TestStubs.cpp \ diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp index a69099bd5..1b02fab86 100644 --- a/test/TileCacheTests.cpp +++ b/test/TileCacheTests.cpp @@ -1090,7 +1090,7 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st std::istringstream istr(response.substr(8)); std::getline(istr, line); - std::vector<std::string> tokens(LOOLProtocol::tokenize(line, ' ')); + StringVector tokens(LOOLProtocol::tokenize(line, ' ')); #if defined CPPUNIT_ASSERT_GREATEREQUAL if (docType == "presentation") CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.size()); // We have an extra field. @@ -1200,7 +1200,7 @@ void TileCacheTests::requestTiles(std::shared_ptr<LOOLWebSocket>& socket, sendTextFrame(socket, text, name); tile = assertResponseString(socket, "tile:", name); // expected tile: part= width= height= tileposx= tileposy= tilewidth= tileheight= - std::vector<std::string> tokens(LOOLProtocol::tokenize(tile, ' ')); + StringVector tokens(LOOLProtocol::tokenize(tile, ' ')); CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tokens[0]); CPPUNIT_ASSERT_EQUAL(0, std::stoi(tokens[1].substr(std::string("nviewid=").size()))); CPPUNIT_ASSERT_EQUAL(part, std::stoi(tokens[2].substr(std::string("part=").size()))); @@ -1348,7 +1348,7 @@ void TileCacheTests::testTileProcessed() ++arrivedTile; // Store tileID, so we can send it back - std::vector<std::string> tokens(LOOLProtocol::tokenize(tile, ' ')); + StringVector tokens(LOOLProtocol::tokenize(tile, ' ')); std::string tileID = tokens[2].substr(std::string("part=").size()) + ":" + tokens[5].substr(std::string("tileposx=").size()) + ":" + tokens[6].substr(std::string("tileposy=").size()) + ":" + @@ -1396,7 +1396,7 @@ void TileCacheTests::testTileInvalidatedOutside() // First wsd forwards the invalidation std::string sInvalidate = assertResponseString(socket, "invalidatetiles:", testname); - std::vector<std::string> tokens(LOOLProtocol::tokenize(sInvalidate, ' ')); + StringVector tokens(LOOLProtocol::tokenize(sInvalidate, ' ')); int y = std::stoi(tokens[3].substr(std::string("y=").size())); int height = std::stoi(tokens[5].substr(std::string("height=").size())); diff --git a/test/UnitAdmin.cpp b/test/UnitAdmin.cpp index b28caa467..92d2d6c34 100644 --- a/test/UnitAdmin.cpp +++ b/test/UnitAdmin.cpp @@ -140,7 +140,7 @@ private: } lock.unlock(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 1 || tokens[0] != "NotAuthenticated") { @@ -171,7 +171,7 @@ private: } lock.unlock(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 1 || tokens[0] != "InvalidAuthToken") { @@ -223,7 +223,7 @@ private: lock.unlock(); { - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 5 || tokens[0] != "adddoc" || tokens[2] != documentPath1.substr(documentPath1.find_last_of('/') + 1) ) @@ -251,7 +251,7 @@ private: lock.unlock(); { - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 5 || tokens[0] != "adddoc" || tokens[2] != documentPath1.substr(documentPath1.find_last_of('/') + 1) ) @@ -286,7 +286,7 @@ private: lock.unlock(); { - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 5 || tokens[0] != "adddoc" || tokens[2] != documentPath2.substr(documentPath2.find_last_of('/') + 1) ) @@ -319,7 +319,7 @@ private: } lock.unlock(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 2 || tokens[0] != "active_users_count") { @@ -352,7 +352,7 @@ private: } lock.unlock(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 2 || tokens[0] != "active_docs_count" || std::stoi(tokens[1]) != _docsCount) @@ -388,7 +388,7 @@ private: } lock.unlock(); - std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); + StringVector tokens(LOOLProtocol::tokenize(_messageReceived, ' ')); if (tokens.size() != 3 || tokens[0] != "rmdoc" || stoi(tokens[1]) != _docPid1) diff --git a/test/UnitBadDocLoad.cpp b/test/UnitBadDocLoad.cpp index 7fe0f74e3..470d8ad09 100644 --- a/test/UnitBadDocLoad.cpp +++ b/test/UnitBadDocLoad.cpp @@ -57,7 +57,7 @@ UnitBase::TestResult UnitBadDocLoad::testBadDocLoadFail() helpers::sendTextFrame(socket, "load url=" + documentURL, testname); const auto response = helpers::getResponseString(socket, "error:", testname); - std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' ')); + StringVector tokens(LOOLProtocol::tokenize(response, ' ')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size()); std::string errorCommand; diff --git a/test/UnitClose.cpp b/test/UnitClose.cpp index fb1718ccc..3da8b4e00 100644 --- a/test/UnitClose.cpp +++ b/test/UnitClose.cpp @@ -194,7 +194,7 @@ UnitBase::TestResult UnitClose::testAlertAllUsers() { const std::string response = helpers::assertResponseString(socket[i], "error:", testname); - std::vector<std::string> tokens(LOOLProtocol::tokenize(response.substr(6), ' ')); + StringVector tokens(LOOLProtocol::tokenize(response.substr(6), ' ')); std::string cmd; LOOLProtocol::getTokenString(tokens, "cmd", cmd); CPPUNIT_ASSERT_EQUAL(std::string("internal"), cmd); diff --git a/test/UnitCursor.cpp b/test/UnitCursor.cpp index a70ef749e..1aac1b011 100644 --- a/test/UnitCursor.cpp +++ b/test/UnitCursor.cpp @@ -34,7 +34,7 @@ void getCursor(const std::string& message, int& cursorX, int& cursorY, int& curs CPPUNIT_ASSERT_EQUAL(std::string(".uno:CellCursor"), text); text = command->get("commandValues").toString(); CPPUNIT_ASSERT(!text.empty()); - std::vector<std::string> position(LOOLProtocol::tokenize(text, ',')); + StringVector position(LOOLProtocol::tokenize(text, ',')); cursorX = std::stoi(position[0]); cursorY = std::stoi(position[1]); cursorWidth = std::stoi(position[2]); diff --git a/test/UnitInsertDelete.cpp b/test/UnitInsertDelete.cpp index 485e43de8..4c2606eea 100644 --- a/test/UnitInsertDelete.cpp +++ b/test/UnitInsertDelete.cpp @@ -35,7 +35,7 @@ void getPartHashCodes(const std::string& testname, const std::string& response, TST_LOG("Reading parts from [" << response << "]."); // Expected format is something like 'type= parts= current= width= height= viewid= [hiddenparts=]'. - std::vector<std::string> tokens(LOOLProtocol::tokenize(line, ' ')); + StringVector tokens(LOOLProtocol::tokenize(line, ' ')); #if defined CPPUNIT_ASSERT_GREATEREQUAL CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.size()); #else @@ -274,7 +274,7 @@ UnitBase::TestResult UnitInsertDelete::testCursorPosition() const auto& command0 = result0.extract<Poco::JSON::Object::Ptr>(); CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command0->has("rectangle")); - std::vector<std::string> cursorTokens( + StringVector cursorTokens( LOOLProtocol::tokenize(command0->get("rectangle").toString(), ',')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), cursorTokens.size()); @@ -290,7 +290,7 @@ UnitBase::TestResult UnitInsertDelete::testCursorPosition() const auto& command = result.extract<Poco::JSON::Object::Ptr>(); CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command->has("rectangle")); - std::vector<std::string> viewTokens( + StringVector viewTokens( LOOLProtocol::tokenize(command->get("rectangle").toString(), ',')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), viewTokens.size()); diff --git a/test/UnitLoad.cpp b/test/UnitLoad.cpp index 4af7ea8fd..e05b47f06 100644 --- a/test/UnitLoad.cpp +++ b/test/UnitLoad.cpp @@ -159,7 +159,7 @@ UnitBase::TestResult UnitLoad::testExcelLoad() const auto status = helpers::assertResponseString(socket, "status:", testname); // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142 viewid=0\n...'. - std::vector<std::string> tokens(LOOLProtocol::tokenize(status, ' ')); + StringVector tokens(LOOLProtocol::tokenize(status, ' ')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.size()); } catch (const Poco::Exception& exc) diff --git a/test/UnitPasswordProtected.cpp b/test/UnitPasswordProtected.cpp index 7eac89f45..8630bc931 100644 --- a/test/UnitPasswordProtected.cpp +++ b/test/UnitPasswordProtected.cpp @@ -51,7 +51,7 @@ UnitBase::TestResult UnitPasswordProtected::testPasswordProtectedDocumentWithout helpers::sendTextFrame(socket, "load url=" + documentURL); const auto response = helpers::getResponseString(socket, "error:", testname); - std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' ')); + StringVector tokens(LOOLProtocol::tokenize(response, ' ')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size()); std::string errorCommand; @@ -87,7 +87,7 @@ UnitBase::TestResult UnitPasswordProtected::testPasswordProtectedDocumentWithWro helpers::sendTextFrame(socket, "load url=" + documentURL + " password=2"); const auto response = helpers::getResponseString(socket, "error:", testname); - std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' ')); + StringVector tokens(LOOLProtocol::tokenize(response, ' ')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size()); std::string errorCommand; diff --git a/test/UnitRenderingOptions.cpp b/test/UnitRenderingOptions.cpp index 6437fbc1f..939de3dc4 100644 --- a/test/UnitRenderingOptions.cpp +++ b/test/UnitRenderingOptions.cpp @@ -51,7 +51,7 @@ void UnitRenderingOptions::invokeTest() // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'. - std::vector<std::string> tokens(LOOLProtocol::tokenize(status, ' ')); + StringVector tokens(LOOLProtocol::tokenize(status, ' ')); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.size()); const std::string token = tokens[5]; diff --git a/test/UnitSession.cpp b/test/UnitSession.cpp index 422a3e01b..86580b04b 100644 --- a/test/UnitSession.cpp +++ b/test/UnitSession.cpp @@ -184,7 +184,7 @@ UnitBase::TestResult UnitSession::testSlideShow() CPPUNIT_ASSERT_MESSAGE("did not receive a downloadas: message as expected", !response.empty()); - std::vector<std::string> tokens(LOOLProtocol::tokenize(response.substr(11), ' ')); + StringVector tokens(LOOLProtocol::tokenize(response.substr(11), ' ')); // "downloadas: jail= dir= name=slideshow.svg port= id=slideshow" const std::string jail = tokens[0].substr(std::string("jail=").size()); const std::string dir = tokens[1].substr(std::string("dir=").size()); diff --git a/test/UnitWOPIWatermark.cpp b/test/UnitWOPIWatermark.cpp index b6de3cd90..042e22fdb 100644 --- a/test/UnitWOPIWatermark.cpp +++ b/test/UnitWOPIWatermark.cpp @@ -136,7 +136,7 @@ public: if(!tile.empty()) { - std::vector<std::string> tokens(LOOLProtocol::tokenize(tile, ' ')); + StringVector tokens(LOOLProtocol::tokenize(tile, ' ')); std::string nviewid = tokens[1].substr(std::string("nviewid=").size()); if (!nviewid.empty() && nviewid != "0") { diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp index 9ccb733ec..67dd8644a 100644 --- a/test/WhiteBoxTests.cpp +++ b/test/WhiteBoxTests.cpp @@ -79,7 +79,7 @@ void WhiteBoxTests::testLOOLProtocolFunctions() CPPUNIT_ASSERT_EQUAL(2, mumble); std::string message("hello x=1 y=2 foo=42 bar=hello-sailor mumble='goodbye' zip zap"); - std::vector<std::string> tokens(LOOLProtocol::tokenize(message)); + StringVector tokens(LOOLProtocol::tokenize(message)); CPPUNIT_ASSERT(LOOLProtocol::getTokenInteger(tokens, "foo", foo)); CPPUNIT_ASSERT_EQUAL(42, foo); @@ -309,7 +309,7 @@ void WhiteBoxTests::testMessageAbbreviation() void WhiteBoxTests::testTokenizer() { - std::vector<std::string> tokens; + StringVector tokens; tokens = LOOLProtocol::tokenize(""); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), tokens.size()); diff --git a/test/helpers.hpp b/test/helpers.hpp index 32ed6efc7..1c02530d9 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -556,7 +556,7 @@ inline void parseDocSize(const std::string& message, const std::string& type, int& part, int& parts, int& width, int& height, int& viewid) { - std::vector<std::string> tokens(LOOLProtocol::tokenize(message, ' ')); + StringVector tokens(LOOLProtocol::tokenize(message, ' ')); // Expected format is something like 'type= parts= current= width= height='. const std::string text = tokens[0].substr(std::string("type=").size()); @@ -585,7 +585,7 @@ std::vector<char> assertTileMessage(LOOLWebSocket& ws, const std::string& testna const std::vector<char> response = getTileMessage(ws, testname); const std::string firstLine = LOOLProtocol::getFirstLine(response); - std::vector<std::string> tileTokens(LOOLProtocol::tokenize(firstLine, ' ')); + StringVector tileTokens(LOOLProtocol::tokenize(firstLine, ' ')); CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tileTokens[0]); CPPUNIT_ASSERT_EQUAL(std::string("part="), tileTokens[1].substr(0, std::string("part=").size())); CPPUNIT_ASSERT_EQUAL(std::string("width="), tileTokens[2].substr(0, std::string("width=").size())); diff --git a/tools/Connect.cpp b/tools/Connect.cpp index af448f3c9..0fcd3ab4c 100644 --- a/tools/Connect.cpp +++ b/tools/Connect.cpp @@ -90,7 +90,7 @@ public: } std::string firstLine = getFirstLine(buffer, n); - std::vector<std::string> tokens(LOOLProtocol::tokenize(firstLine, ' ')); + StringVector tokens(LOOLProtocol::tokenize(firstLine, ' ')); if (std::getenv("DISPLAY") != nullptr && tokens[0] == "tile:") { diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index f734785a2..3a58adc63 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -89,7 +89,7 @@ protected: std::string line; std::getline(std::cin, line); - std::vector<std::string> tokens(LOOLProtocol::tokenize(line, ' ')); + StringVector tokens(LOOLProtocol::tokenize(line, ' ')); if (tokens.size() == 0) continue; diff --git a/tools/WebSocketDump.cpp b/tools/WebSocketDump.cpp index 94371a18c..5ea8f6da7 100644 --- a/tools/WebSocketDump.cpp +++ b/tools/WebSocketDump.cpp @@ -135,7 +135,7 @@ private: LOG_INF("Incoming websocket request: " << request.getURI()); const std::string& requestURI = request.getURI(); - std::vector<std::string> pathTokens(LOOLProtocol::tokenize(requestURI, '/')); + StringVector pathTokens(LOOLProtocol::tokenize(requestURI, '/')); if (request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0) { auto dumpHandler = std::make_shared<DumpSocketHandler>(_socket, request); diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index db74b1535..cfd39885c 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -53,7 +53,7 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */, { // FIXME: check fin, code etc. const std::string firstLine = getFirstLine(payload.data(), payload.size()); - std::vector<std::string> tokens(LOOLProtocol::tokenize(firstLine, ' ')); + StringVector tokens(LOOLProtocol::tokenize(firstLine, ' ')); LOG_TRC("Recv: " << firstLine << " tokens " << tokens.size()); if (tokens.empty()) @@ -196,7 +196,7 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */, { for (size_t i = 1; i < tokens.size(); i++) { - std::vector<std::string> setting(LOOLProtocol::tokenize(tokens[i], '=')); + StringVector setting(LOOLProtocol::tokenize(tokens[i], '=')); int settingVal = 0; try { @@ -318,7 +318,7 @@ bool AdminSocketHandler::handleInitialRequest( std::shared_ptr<StreamSocket> socket = socketWeak.lock(); const std::string& requestURI = request.getURI(); - std::vector<std::string> pathTokens(LOOLProtocol::tokenize(requestURI, '/')); + StringVector pathTokens(LOOLProtocol::tokenize(requestURI, '/')); if (request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0) { diff --git a/wsd/Auth.cpp b/wsd/Auth.cpp index 9e93f5c29..514a3d508 100644 --- a/wsd/Auth.cpp +++ b/wsd/Auth.cpp @@ -101,7 +101,7 @@ const std::string JWTAuth::getAccessToken() bool JWTAuth::verify(const std::string& accessToken) { - std::vector<std::string> tokens(LOOLProtocol::tokenize(accessToken, '.')); + StringVector tokens(LOOLProtocol::tokenize(accessToken, '.')); try { diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 75106c162..fedbf422e 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -324,7 +324,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) { LOG_TRC(getName() << ": handling incoming [" << getAbbreviatedMessage(buffer, length) << "]."); const std::string firstLine = getFirstLine(buffer, length); - const std::vector<std::string> tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size()); + const StringVector tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size()); std::shared_ptr<DocumentBroker> docBroker = getDocumentBroker(); if (!docBroker || docBroker->isMarkedToDestroy()) @@ -758,7 +758,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) } bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, - const std::vector<std::string>& tokens, + const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker) { if (tokens.size() < 2) @@ -849,7 +849,7 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, return false; } -bool ClientSession::getCommandValues(const char *buffer, int length, const std::vector<std::string>& tokens, +bool ClientSession::getCommandValues(const char *buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker) { std::string command; @@ -863,7 +863,7 @@ bool ClientSession::getCommandValues(const char *buffer, int length, const std:: return forwardToChild(std::string(buffer, length), docBroker); } -bool ClientSession::sendFontRendering(const char *buffer, int length, const std::vector<std::string>& tokens, +bool ClientSession::sendFontRendering(const char *buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker) { std::string font, text; @@ -885,7 +885,7 @@ bool ClientSession::sendFontRendering(const char *buffer, int length, const std: return forwardToChild(std::string(buffer, length), docBroker); } -bool ClientSession::sendTile(const char * /*buffer*/, int /*length*/, const std::vector<std::string>& tokens, +bool ClientSession::sendTile(const char * /*buffer*/, int /*length*/, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker) { try @@ -903,7 +903,7 @@ bool ClientSession::sendTile(const char * /*buffer*/, int /*length*/, const std: return true; } -bool ClientSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens, +bool ClientSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker) { try @@ -931,7 +931,7 @@ bool ClientSession::forwardToChild(const std::string& message, bool ClientSession::filterMessage(const std::string& message) const { bool allowed = true; - std::vector<std::string> tokens(LOOLProtocol::tokenize(message, ' ')); + StringVector tokens(LOOLProtocol::tokenize(message, ' ')); // Set allowed flag to false depending on if particular WOPI properties are set if (tokens[0] == "downloadas") @@ -1282,7 +1282,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt #endif else if (tokens.size() == 2 && tokens[0] == "statechanged:") { - std::vector<std::string> stateTokens(LOOLProtocol::tokenize(tokens[1], '=')); + StringVector stateTokens(LOOLProtocol::tokenize(tokens[1], '=')); if (stateTokens.size() == 2 && stateTokens[0] == ".uno:ModifiedStatus") { docBroker->setModified(stateTokens[1] == "true"); @@ -1471,7 +1471,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt const Poco::Dynamic::Var result = parser.parse(stringJSON); const auto& object = result.extract<Poco::JSON::Object::Ptr>(); const std::string rectangle = object->get("rectangle").toString(); - std::vector<std::string> rectangleTokens(LOOLProtocol::tokenize(rectangle, ',')); + StringVector rectangleTokens(LOOLProtocol::tokenize(rectangle, ',')); int x = 0, y = 0, w = 0, h = 0; if (rectangleTokens.size() > 2 && stringToInteger(rectangleTokens[0], x) && diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp index d714179ce..e04a01641 100644 --- a/wsd/ClientSession.hpp +++ b/wsd/ClientSession.hpp @@ -187,18 +187,18 @@ private: virtual bool _handleInput(const char* buffer, int length) override; - bool loadDocument(const char* buffer, int length, const std::vector<std::string>& tokens, + bool loadDocument(const char* buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker); bool getStatus(const char* buffer, int length, const std::shared_ptr<DocumentBroker>& docBroker); - bool getCommandValues(const char* buffer, int length, const std::vector<std::string>& tokens, + bool getCommandValues(const char* buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker); - bool sendTile(const char* buffer, int length, const std::vector<std::string>& tokens, + bool sendTile(const char* buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker); - bool sendCombinedTiles(const char* buffer, int length, const std::vector<std::string>& tokens, + bool sendCombinedTiles(const char* buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker); - bool sendFontRendering(const char* buffer, int length, const std::vector<std::string>& tokens, + bool sendFontRendering(const char* buffer, int length, const StringVector& tokens, const std::shared_ptr<DocumentBroker>& docBroker); bool forwardToChild(const std::string& message, diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 88c22a303..bdb3d61ed 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -777,7 +777,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s const std::string newRootPath = _storage->getRootFilePath() + "." + newExtension; - std::vector<std::string> args(LOOLProtocol::tokenize(commandLine, ' ')); + StringVector args(LOOLProtocol::tokenize(commandLine, ' ')); std::string command(args[0]); args.erase(args.begin()); // strip the command @@ -2012,7 +2012,7 @@ bool DocumentBroker::forwardToChild(const std::string& viewId, const std::string { assert(!_uriJailed.empty()); - std::vector<std::string> tokens = LOOLProtocol::tokenize(msg); + StringVector tokens = LOOLProtocol::tokenize(msg); if (tokens.size() > 1 && tokens[1] == "load") { // The json options must come last. diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 55942611e..d7db1e80c 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -145,7 +145,7 @@ bool isConfigAuthOk(const std::string& userProvidedUsr, const std::string& userP #if HAVE_PKCS5_PBKDF2_HMAC // Extract the salt from the config std::vector<unsigned char> saltData; - std::vector<std::string> tokens = LOOLProtocol::tokenize(securePass, '.'); + StringVector tokens = LOOLProtocol::tokenize(securePass, '.'); if (tokens.size() != 5 || tokens[0] != "pbkdf2" || tokens[1] != "sha512" || diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index f9fc062e2..d84f77b91 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1602,7 +1602,7 @@ bool LOOLWSD::createForKit() std::unique_lock<std::mutex> newChildrenLock(NewChildrenMutex); - std::vector<std::string> args; + StringVector args; #ifdef STRACE_LOOLFORKIT // if you want to use this, you need to setcap cap_fowner,cap_mknod,cap_sys_chroot=ep /usr/bin/strace args.push_back("-o"); @@ -2062,7 +2062,7 @@ public: if(request.has("X-Forwarded-For")) { const std::string fowardedData = request.get("X-Forwarded-For"); - std::vector<std::string> tokens = LOOLProtocol::tokenize(fowardedData, ','); + StringVector tokens = LOOLProtocol::tokenize(fowardedData, ','); for(std::string& token : tokens) { addressToCheck = Util::trim(token); diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 53579d2da..a9caad8bb 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -418,7 +418,7 @@ static void addStorageDebugCookie(Poco::Net::HTTPRequest& request) if (std::getenv("LOOL_STORAGE_COOKIE")) { Poco::Net::NameValueCollection nvcCookies; - std::vector<std::string> cookieTokens = LOOLProtocol::tokenize(std::string(std::getenv("LOOL_STORAGE_COOKIE")), ':'); + StringVector cookieTokens = LOOLProtocol::tokenize(std::string(std::getenv("LOOL_STORAGE_COOKIE")), ':'); if (cookieTokens.size() == 2) { nvcCookies.add(cookieTokens[0], cookieTokens[1]); @@ -436,10 +436,10 @@ static void addStorageReuseCookie(Poco::Net::HTTPRequest& request, const std::st Poco::Net::NameValueCollection nvcCookies; request.getCookies(nvcCookies); // Preserve existing cookies. - std::vector<std::string> cookies = LOOLProtocol::tokenize(reuseStorageCookies, ':'); + StringVector cookies = LOOLProtocol::tokenize(reuseStorageCookies, ':'); for (auto cookie : cookies) { - std::vector<std::string> cookieTokens = LOOLProtocol::tokenize(cookie, '='); + StringVector cookieTokens = LOOLProtocol::tokenize(cookie, '='); if (cookieTokens.size() == 2) { nvcCookies.add(cookieTokens[0], cookieTokens[1]); diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp index 651182078..3211e336e 100644 --- a/wsd/TileCache.cpp +++ b/wsd/TileCache.cpp @@ -321,7 +321,7 @@ void TileCache::invalidateTiles(const std::string& tiles, int normalizedViewId) std::pair<int, Util::Rectangle> TileCache::parseInvalidateMsg(const std::string& tiles) { - std::vector<std::string> tokens = LOOLProtocol::tokenize(tiles); + StringVector tokens = LOOLProtocol::tokenize(tiles); assert(tokens.size() > 0 && tokens[0] == "invalidatetiles:"); diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp index a7e855ecc..d1296f0c8 100644 --- a/wsd/TileDesc.hpp +++ b/wsd/TileDesc.hpp @@ -196,7 +196,7 @@ public: } /// Deserialize a TileDesc from a tokenized string. - static TileDesc parse(const std::vector<std::string>& tokens) + static TileDesc parse(const StringVector& tokens) { // We don't expect undocumented fields and // assume all values to be int. @@ -300,12 +300,12 @@ private: throw BadArgumentException("Invalid tilecombine descriptor."); } - std::vector<std::string> positionXtokens(LOOLProtocol::tokenize(tilePositionsX, ',')); - std::vector<std::string> positionYtokens(LOOLProtocol::tokenize(tilePositionsY, ',')); - std::vector<std::string> imgSizeTokens(LOOLProtocol::tokenize(imgSizes, ',')); - std::vector<std::string> verTokens(LOOLProtocol::tokenize(vers, ',')); - std::vector<std::string> oldWireIdTokens(LOOLProtocol::tokenize(oldWireIds, ',')); - std::vector<std::string> wireIdTokens(LOOLProtocol::tokenize(wireIds, ',')); + StringVector positionXtokens(LOOLProtocol::tokenize(tilePositionsX, ',')); + StringVector positionYtokens(LOOLProtocol::tokenize(tilePositionsY, ',')); + StringVector imgSizeTokens(LOOLProtocol::tokenize(imgSizes, ',')); + StringVector verTokens(LOOLProtocol::tokenize(vers, ',')); + StringVector oldWireIdTokens(LOOLProtocol::tokenize(oldWireIds, ',')); + StringVector wireIdTokens(LOOLProtocol::tokenize(wireIds, ',')); const size_t numberOfPositions = positionXtokens.size(); @@ -455,7 +455,7 @@ public: } /// Deserialize a TileDesc from a tokenized string. - static TileCombined parse(const std::vector<std::string>& tokens) + static TileCombined parse(const StringVector& tokens) { // We don't expect undocumented fields and // assume all values to be int. diff --git a/wsd/TraceFile.hpp b/wsd/TraceFile.hpp index e95fbb2e2..466e06fbc 100644 --- a/wsd/TraceFile.hpp +++ b/wsd/TraceFile.hpp @@ -199,7 +199,7 @@ public: // Remap the URL to the snapshot. if (LOOLProtocol::matchPrefix("load", data)) { - std::vector<std::string> tokens = LOOLProtocol::tokenize(data); + StringVector tokens = LOOLProtocol::tokenize(data); if (tokens.size() >= 2) { std::string url; |