mirror of https://github.com/Icinga/icinga2.git
parent
d1d3c0e247
commit
6ccf4497f2
|
@ -499,7 +499,7 @@ String Utility::EscapeShellCmd(const String& s)
|
|||
|
||||
if (escape)
|
||||
#ifdef _WIN32
|
||||
result += '%';
|
||||
result += '^';
|
||||
#else /* _WIN32 */
|
||||
result += '\\';
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "base/scriptfunction.h"
|
||||
#include "base/utility.h"
|
||||
#include "base/process.h"
|
||||
#include "base/objectlock.h"
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -123,6 +124,8 @@ String PluginUtility::FormatPerfdata(const Value& perfdata)
|
|||
|
||||
Dictionary::Ptr dict = perfdata;
|
||||
|
||||
ObjectLock olock(dict);
|
||||
|
||||
String key;
|
||||
Value value;
|
||||
BOOST_FOREACH(boost::tie(key, value), dict) {
|
||||
|
|
|
@ -29,18 +29,17 @@ BOOST_AUTO_TEST_CASE(escape_basic)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("%PATH%") == "^%PATH^%");
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#else /* _WIN32 */
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("$PATH") == "\\$PATH");
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("\\$PATH") == "\\\\\\$PATH");
|
||||
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(escape_quoted)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "\\'hello\\'");
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("\"hello\"") == "\\\"hello\\\"");
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "^'hello^'");
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("\"hello\"") == "^\"hello^\"");
|
||||
#else /* _WIN32 */
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "'hello'");
|
||||
BOOST_CHECK(Utility::EscapeShellCmd("'hello") == "\\'hello");
|
||||
|
|
Loading…
Reference in New Issue