From 1d238b70e2655e64b1cb1a51357a9eb0c753181d Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Wed, 5 Oct 2022 13:57:24 +0200 Subject: Escape poll options (#128) --- src/tools/StringTools.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/tools') diff --git a/src/tools/StringTools.cpp b/src/tools/StringTools.cpp index 653047c..3e5e6c4 100644 --- a/src/tools/StringTools.cpp +++ b/src/tools/StringTools.cpp @@ -101,4 +101,22 @@ string urlDecode(const string& value) { return result; } +std::string escapeJsonString(const std::string& value) { + string result; + + for (const char& c : value) { + switch (c) { + case '"': + case '\\': + case '/': + result += '\\'; + break; + } + + result += c; + } + + return result; +} + } -- cgit v1.2.3