Fix macros substitutions

This commit is contained in:
Mattia Codato 2020-07-31 11:15:17 +02:00
parent 44fc841ee1
commit 604b938ade

View File

@ -619,8 +619,9 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
endpoint = HttpUtility::GetLastParameter(params, "endpoint"); endpoint = HttpUtility::GetLastParameter(params, "endpoint");
MacroProcessor::ResolverList resolvers; MacroProcessor::ResolverList resolvers;
Value macros;
if (params->Contains("macros")) { if (params->Contains("macros")) {
Value macros = HttpUtility::GetLastParameter(params, "macros"); macros = HttpUtility::GetLastParameter(params, "macros");
if (macros.IsObjectType<Dictionary>()) { if (macros.IsObjectType<Dictionary>()) {
resolvers.emplace_back("override", macros); resolvers.emplace_back("override", macros);
} }
@ -673,7 +674,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
/* Check if resolved_command exists and it is of type command_type */ /* Check if resolved_command exists and it is of type command_type */
Dictionary::Ptr execMacros = new Dictionary(); Dictionary::Ptr execMacros = new Dictionary();
MacroResolver::OverrideMacros = execMacros; MacroResolver::OverrideMacros = macros;
Defer o ([]() { Defer o ([]() {
MacroResolver::OverrideMacros = nullptr; MacroResolver::OverrideMacros = nullptr;
}); });