Escape linefeeds and carriage returns in commands and show them as html
fixes #6088
This commit is contained in:
parent
666591beb7
commit
dc8181cdc5
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ foreach ($object->comments as $comment) {
|
|||
);
|
||||
|
||||
$list[] = sprintf(
|
||||
'<tr><th>%s (%s)</th><td data-base-target="_self">%s (%s) %s</td></tr>',
|
||||
'<tr><th>%s (%s)</th><td><table><tr><td style="vertical-align: top;" data-base-target="_self">%s (%s):</td><td style="padding-left: .5em;">%s</td></tr></table></td></tr>',
|
||||
$this->escape($comment->author),
|
||||
$this->timeSince($comment->timestamp),
|
||||
$iconForm,
|
||||
ucfirst($comment->type),
|
||||
$text
|
||||
str_replace(array('\r\n', '\n'), '<br>', $text)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ foreach ($object->downtimes as $downtime) {
|
|||
) : $this->escape($downtime->comment);
|
||||
|
||||
$list[] = sprintf(
|
||||
'<tr><th>%s</th><td data-base-target="_self">%s %s: %s</td></tr>',
|
||||
'<tr><th>%s</th><td><table><tr><td style="vertical-align: top;" data-base-target="_self">%s %s:</td><td style="padding-left: .5em;">%s</td></tr></table></td></tr>',
|
||||
$this->escape($downtime->author),
|
||||
$iconForm,
|
||||
$state,
|
||||
$text
|
||||
str_replace(array('\r\n', '\n'), '<br>', $text)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue