mirror of https://github.com/Icinga/icinga2.git
compat: Escape new-lines in commands.
This commit is contained in:
parent
76edc08506
commit
049fbcb3cb
|
@ -266,10 +266,10 @@ void CompatComponent::DumpCommand(std::ostream& fp, const Command::Ptr& command)
|
||||||
String arg;
|
String arg;
|
||||||
BOOST_FOREACH(arg, args) {
|
BOOST_FOREACH(arg, args) {
|
||||||
// This is obviously incorrect for non-trivial cases.
|
// This is obviously incorrect for non-trivial cases.
|
||||||
fp << " \"" << arg << "\"";
|
fp << " \"" << EscapeString(arg) << "\"";
|
||||||
}
|
}
|
||||||
} else if (!commandLine.IsEmpty()) {
|
} else if (!commandLine.IsEmpty()) {
|
||||||
fp << Convert::ToString(commandLine);
|
fp << EscapeString(Convert::ToString(commandLine));
|
||||||
} else {
|
} else {
|
||||||
fp << "<internal>";
|
fp << "<internal>";
|
||||||
}
|
}
|
||||||
|
@ -391,6 +391,13 @@ void CompatComponent::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String CompatComponent::EscapeString(const String& str)
|
||||||
|
{
|
||||||
|
String result = str;
|
||||||
|
boost::algorithm::replace_all(result, "\n", "\\n");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Ptr& service, CompatObjectType type)
|
void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Ptr& service, CompatObjectType type)
|
||||||
{
|
{
|
||||||
ASSERT(service->OwnsLock());
|
ASSERT(service->OwnsLock());
|
||||||
|
@ -428,7 +435,7 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
||||||
|
|
||||||
if (line_end > 0 && line_end != String::NPos) {
|
if (line_end > 0 && line_end != String::NPos) {
|
||||||
long_output = raw_output.SubStr(line_end+1, raw_output.GetLength());
|
long_output = raw_output.SubStr(line_end+1, raw_output.GetLength());
|
||||||
boost::algorithm::replace_all(long_output, "\n", "\\n");
|
long_output = EscapeString(long_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::algorithm::replace_all(output, "\n", "\\n");
|
boost::algorithm::replace_all(output, "\n", "\\n");
|
||||||
|
|
|
@ -112,6 +112,8 @@ private:
|
||||||
void DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object);
|
void DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object);
|
||||||
|
|
||||||
void StatusTimerHandler(void);
|
void StatusTimerHandler(void);
|
||||||
|
|
||||||
|
static String EscapeString(const String& str);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue