From 373b88df33811f99cf92fced4d41028dc717df9f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 27 Aug 2015 08:57:56 +0200 Subject: [PATCH] Implement the escape_shell_arg and escape_shell_cmd functions fixes #10004 --- doc/20-library-reference.md | 2 ++ lib/base/scriptutils.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/20-library-reference.md b/doc/20-library-reference.md index dca6294cd..9531b1df4 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. exit(integer) | Terminates the application. ## Object Accessor Functions diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index 4d62522d9..5651b29d1 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -59,6 +59,8 @@ REGISTER_SAFE_SCRIPTFUNCTION(basename, &Utility::BaseName); REGISTER_SAFE_SCRIPTFUNCTION(dirname, &Utility::DirName); REGISTER_SAFE_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim); REGISTER_SAFE_SCRIPTFUNCTION(track_parents, &ScriptUtils::TrackParents); +REGISTER_SAFE_SCRIPTFUNCTION(escape_shell_cmd, &Utility::EscapeShellCmd); +REGISTER_SAFE_SCRIPTFUNCTION(escape_shell_arg, &Utility::EscapeShellArg); String ScriptUtils::CastString(const Value& value) { -- 2.50.1