]> granicus.if.org Git - icinga2/commitdiff
Missing macros in nested macro() calls should not cause the outer macro resolution...
authorGunnar Beutner <gunnar@beutner.name>
Thu, 27 Aug 2015 06:58:25 +0000 (08:58 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 27 Aug 2015 07:02:21 +0000 (09:02 +0200)
fixes #10003

lib/icinga/macroprocessor.cpp
lib/icinga/macroprocessor.hpp

index 07f38b42917ecddae24449e6c2a8010e2eeb266e..7b712960e28610421fdafeadd7a7622cb29cc09c 100644 (file)
@@ -78,7 +78,7 @@ Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolv
 
                result = resultDict;
        } else if (str.IsObjectType<Function>()) {
-               result = EvaluateFunction(str, resolvers, cr, missingMacro, escapeFn, resolvedMacros, useResolvedMacros, 0);
+               result = EvaluateFunction(str, resolvers, cr, escapeFn, resolvedMacros, useResolvedMacros, 0);
        } else {
                BOOST_THROW_EXCEPTION(std::invalid_argument("Macro is not a string or array."));
        }
@@ -175,21 +175,21 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol
 }
 
 Value MacroProcessor::InternalResolveMacrosShim(const std::vector<Value>& args, const ResolverList& resolvers,
-    const CheckResult::Ptr& cr, String *missingMacro,
-    const MacroProcessor::EscapeCallback& escapeFn, const Dictionary::Ptr& resolvedMacros,
+    const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn, const Dictionary::Ptr& resolvedMacros,
     bool useResolvedMacros, int recursionLevel)
 {
        if (args.size() < 1)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
 
-       return MacroProcessor::InternalResolveMacros(args[0], resolvers, cr, missingMacro, escapeFn,
+       String missingMacro;
+
+       return MacroProcessor::InternalResolveMacros(args[0], resolvers, cr, &missingMacro, escapeFn,
            resolvedMacros, useResolvedMacros, recursionLevel);
 }
 
 Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const ResolverList& resolvers,
-    const CheckResult::Ptr& cr, String *missingMacro,
-    const MacroProcessor::EscapeCallback& escapeFn, const Dictionary::Ptr& resolvedMacros,
-    bool useResolvedMacros, int recursionLevel)
+    const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn,
+    const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel)
 {
        Dictionary::Ptr resolvers_this = new Dictionary();
 
@@ -198,7 +198,7 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver
        }
 
        resolvers_this->Set("macro", new Function(boost::bind(&MacroProcessor::InternalResolveMacrosShim,
-           _1, boost::cref(resolvers), cr, missingMacro, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros,
+           _1, boost::cref(resolvers), cr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros,
            recursionLevel + 1)));
 
        ScriptFrame frame(resolvers_this);
@@ -249,7 +249,7 @@ Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverLis
                }
 
                if (resolved_macro.IsObjectType<Function>()) {
-                       resolved_macro = EvaluateFunction(resolved_macro, resolvers, cr, missingMacro, escapeFn,
+                       resolved_macro = EvaluateFunction(resolved_macro, resolvers, cr, escapeFn,
                            resolvedMacros, useResolvedMacros, recursionLevel);
                }
 
index a603fcab6d37116666529fecca92d113a828787b..54a08243de008091b3284b4aea02d6a01e8cd947 100644 (file)
@@ -60,13 +60,11 @@ private:
            const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros,
            int recursionLevel = 0);
        static Value InternalResolveMacrosShim(const std::vector<Value>& args, const ResolverList& resolvers,
-           const CheckResult::Ptr& cr, String *missingMacro,
-           const MacroProcessor::EscapeCallback& escapeFn, const Dictionary::Ptr& resolvedMacros,
-           bool useResolvedMacros, int recursionLevel);
+           const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn,
+            const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel);
        static Value EvaluateFunction(const Function::Ptr& func, const ResolverList& resolvers,
-           const CheckResult::Ptr& cr, String *missingMacro,
-           const MacroProcessor::EscapeCallback& escapeFn, const Dictionary::Ptr& resolvedMacros,
-           bool useResolvedMacros, int recursionLevel);
+           const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn,
+           const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel);
 
 };