From: Gunnar Beutner Date: Thu, 27 Aug 2015 06:57:56 +0000 (+0200) Subject: Implement the escape_shell_arg and escape_shell_cmd functions X-Git-Tag: v2.3.11~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a530bb955d903a521d6c8a3659727b7a09b90fe5;p=icinga2 Implement the escape_shell_arg and escape_shell_cmd functions fixes #10004 --- diff --git a/doc/20-library-reference.md b/doc/20-library-reference.md index b452b4a78..b262c7159 100644 --- a/doc/20-library-reference.md +++ b/doc/20-library-reference.md @@ -21,6 +21,8 @@ get_time() | Returns the current UNIX timestamp. parse_performance_data(pd) | Parses a performance data string and returns an array describing the values. dirname(path) | Returns the directory portion of the specified path. basename(path) | Returns the filename portion of the specified path. +escape\_shell\_arg(text) | Escapes a string for use as a single shell argument. +escape\_shell\_cmd(text) | Escapes shell meta characters in a string. escape\_create\_process\_arg(text)| (Windows only) Escapes a string for use as an argument for CreateProcess(). exit(integer) | Terminates the application. diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index 837885b80..f9b5429bf 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -58,10 +58,11 @@ REGISTER_SCRIPTFUNCTION(get_time, &Utility::GetTime); REGISTER_SCRIPTFUNCTION(basename, &Utility::BaseName); REGISTER_SCRIPTFUNCTION(dirname, &Utility::DirName); REGISTER_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim); +REGISTER_SCRIPTFUNCTION(escape_shell_cmd, &Utility::EscapeShellCmd); +REGISTER_SCRIPTFUNCTION(escape_shell_arg, &Utility::EscapeShellArg); #ifdef _WIN32 REGISTER_SCRIPTFUNCTION(escape_create_process_arg, &Utility::EscapeCreateProcessArg); #endif /* _WIN32 */ ->>>>>>> 08ccb4e... Build fix String ScriptUtils::CastString(const Value& value) {