diff --git a/library/Icinga/Protocol/Commandpipe/CommandPipe.php b/library/Icinga/Protocol/Commandpipe/CommandPipe.php
index 91be222cd..8d149dd20 100644
--- a/library/Icinga/Protocol/Commandpipe/CommandPipe.php
+++ b/library/Icinga/Protocol/Commandpipe/CommandPipe.php
@@ -109,7 +109,19 @@ class CommandPipe
*/
public function send($command)
{
- $this->transport->send($command);
+ $this->transport->send($this->escape($command));
+ }
+
+ /**
+ * Return the given command string with escaped newlines
+ *
+ * @param string $command The command string to escape
+ *
+ * @return string The escaped command string
+ */
+ public function escape($command)
+ {
+ return str_replace(array("\r", "\n"), array('\r', '\n'), $command);
}
/**
@@ -121,16 +133,14 @@ class CommandPipe
public function sendCommand(Command $command, array $objects = array())
{
if ($command->provideGlobalCommand() === true) {
- $this->transport->send($command->getGlobalCommand());
+ $this->send($command->getGlobalCommand());
} else {
foreach ($objects as $object) {
$objectType = $this->getObjectType($object);
if ($objectType === self::TYPE_SERVICE) {
- $this->transport->send(
- $command->getServiceCommand($object->host_name, $object->service_description)
- );
+ $this->send($command->getServiceCommand($object->host_name, $object->service_description));
} else {
- $this->transport->send($command->getHostCommand($object->host_name));
+ $this->send($command->getHostCommand($object->host_name));
}
}
}
diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml
index 9623f4fa4..4365acdd5 100644
--- a/modules/monitoring/application/views/scripts/show/components/comments.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml
@@ -31,12 +31,12 @@ foreach ($object->comments as $comment) {
);
$list[] = sprintf(
- '
%s (%s) | %s (%s) %s |
',
+ '%s (%s) | |
',
$this->escape($comment->author),
$this->timeSince($comment->timestamp),
$iconForm,
ucfirst($comment->type),
- $text
+ str_replace(array('\r\n', '\n'), '
', $text)
);
}
diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml
index 34f4e98e4..f78666531 100644
--- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml
@@ -42,11 +42,11 @@ foreach ($object->downtimes as $downtime) {
) : $this->escape($downtime->comment);
$list[] = sprintf(
- '%s | %s %s: %s |
',
+ '%s | |
',
$this->escape($downtime->author),
$iconForm,
$state,
- $text
+ str_replace(array('\r\n', '\n'), '
', $text)
);
}