[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 8 21:23:45 UTC 2019


 wsd/DocumentBroker.cpp |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

New commits:
commit 15dcf613d86a8b96e975b6b6c52420f76a26a60c
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Nov 8 20:52:35 2019 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Nov 8 22:23:25 2019 +0100

    killpoco: More complicated StringTokenizer removal in DocumentBroker.
    
    Change-Id: I55688bfdd5aef49e27dddf56cc47c2ec5834768c
    Reviewed-on: https://gerrit.libreoffice.org/82324
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fd77b83ae..c8b0e811d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -24,7 +24,6 @@
 #include <Poco/Path.h>
 #include <Poco/SHA1Engine.h>
 #include <Poco/StreamCopier.h>
-#include <Poco/StringTokenizer.h>
 
 #include "Admin.hpp"
 #include "ClientSession.hpp"
@@ -743,19 +742,31 @@ 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, ' '));
+                    std::string command(args[0]);
+                    args.erase(args.begin()); // strip the commmand
+
                     // The commandline must contain the space-separated substring @INPUT@ that is
                     // replaced with the input file name, and @OUTPUT@ for the output file name.
-                    Poco::StringTokenizer tokenizer(commandLine, " ");
-                    if (tokenizer.replace("@INPUT@", _storage->getRootFilePath()) != 1 ||
-                        tokenizer.replace("@OUTPUT@", newRootPath) != 1)
-                        throw Poco::NotFoundException();
-
+                    int inputs(0), outputs(0);
+                    for (auto it = args.begin(); it != args.end(); ++it)
+                    {
+                        if (*it == "@INPUT@")
+                        {
+                            *it = _storage->getRootFilePath();
+                            ++inputs;
+                        }
+                        else if (*it == "@OUTPUT@")
+                        {
+                            *it = newRootPath;
+                            ++outputs;
+                        }
+                    }
 
-                    std::vector<std::string> args;
-                    for (std::size_t i = 1; i < tokenizer.count(); ++i)
-                        args.emplace_back(tokenizer[i]);
+                    if (inputs != 1 || outputs != 1)
+                        throw std::exception();
 
-                    int process = Util::spawnProcess(tokenizer[0], args);
+                    int process = Util::spawnProcess(command, args);
                     int status = -1;
                     const int rc = ::waitpid(process, &status, 0);
                     if (rc != 0)
@@ -772,7 +783,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
                 // loop.
                 break;
             }
-            catch (const Poco::NotFoundException&)
+            catch (const std::exception&)
             {
                 // This plugin is not a proper prefilter one
             }


More information about the Libreoffice-commits mailing list