Merge branch 'bugfix/plugin-output-always-escaped-9036'

fixes #9036
This commit is contained in:
Matthias Jentsch 2015-07-07 10:24:54 +02:00
commit 604ef87de8
5 changed files with 14 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
uasort( uasort(
$pieChartData, $pieChartData,
function($a, $b) { function ($a, $b) {
return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0); return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0);
} }
); );

View File

@ -27,24 +27,29 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
'@@@@@@', '@@@@@@',
); );
public function pluginOutput($output) public function pluginOutput($output, $raw = false)
{ {
if (empty($output)) { if (empty($output)) {
return ''; return '';
} }
$output = preg_replace('~<br[^>]+>~', "\n", $output); $output = preg_replace('~<br[^>]+>~', "\n", $output);
if (preg_match('~<\w+[^>^\\\]{,60}>~', $output)) { if (preg_match('~<\w+[^>^\\\]{0,60}>~', $output)) {
// HTML // HTML
$output = preg_replace('~<table~', '<table style="font-size: 0.75em"', $output = preg_replace(
'~<table~',
'<table style="font-size: 0.75em"',
$this->getPurifier()->purify($output) $this->getPurifier()->purify($output)
); );
} else { } else {
// Plaintext // Plaintext
$output = '<pre class="pluginoutput">' . preg_replace( $output = preg_replace(
self::$txtPatterns, self::$txtPatterns,
self::$txtReplacements, self::$txtReplacements,
$this->view->escape($output) $this->view->escape($output)
) . '</pre>'; );
}
if (! $raw) {
$output = '<pre class="pluginoutput">' . $output . '</pre>';
} }
$output = $this->fixLinks($output); $output = $this->fixLinks($output);
return $output; return $output;

View File

@ -90,7 +90,7 @@ if (count($hosts) === 0) {
) )
) ?>)</span> ) ?>)</span>
<?php endif ?> <?php endif ?>
<p class="pluginoutput"><?= $this->escape($this->ellipsis($host->host_output, 10000)) ?></p> <p class="pluginoutput"><?= $this->pluginOutput($this->ellipsis($host->host_output, 10000), true) ?></p>
</td> </td>
<?php foreach($this->addColumns as $col): ?> <?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($host->$col) ?></td> <td><?= $this->escape($host->$col) ?></td>

View File

@ -48,7 +48,7 @@ if (count($notifications) === 0) {
<?= $this->link()->host($notification->host_name, $notification->host_display_name) ?> <?= $this->link()->host($notification->host_name, $notification->host_display_name) ?>
<?php endif ?> <?php endif ?>
<br> <br>
<?= $this->escape($this->ellipsis($notification->notification_output, 10000)) ?> <?= $this->pluginOutput($this->ellipsis($notification->notification_output, 10000), true) ?>
<br> <br>
<?php if (! $this->contact): ?> <?php if (! $this->contact): ?>
<small> <small>

View File

@ -82,7 +82,7 @@ if (count($services) === 0) {
) )
) ?><br /> ) ?><br />
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 5) ?> </div> <div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 5) ?> </div>
<p class="pluginoutput"><?= $this->escape($this->ellipsis($service->service_output, 10000)) ?></p> <p class="pluginoutput"><?= $this->pluginOutput($this->ellipsis($service->service_output, 10000), true) ?></p>
</td> </td>
<?php foreach($this->addColumns as $col): ?> <?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($service->$col) ?></td> <td><?= $this->escape($service->$col) ?></td>