Skip to content

Commit

Permalink
Merge branch 'bugfix/plugin-output-always-escaped-9036'
Browse files Browse the repository at this point in the history
fixes #9036
  • Loading branch information
majentsch committed Jul 7, 2015
2 parents 3098c21 + 4f884b1 commit 604ef87
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/monitoring/application/views/helpers/Perfdata.php
Expand Up @@ -22,7 +22,7 @@ public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Pe
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
uasort(
$pieChartData,
function($a, $b) {
function ($a, $b) {
return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0);
}
);
Expand Down
15 changes: 10 additions & 5 deletions modules/monitoring/application/views/helpers/PluginOutput.php
Expand Up @@ -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)) {
return '';
}
$output = preg_replace('~<br[^>]+>~', "\n", $output);
if (preg_match('~<\w+[^>^\\\]{,60}>~', $output)) {
if (preg_match('~<\w+[^>^\\\]{0,60}>~', $output)) {
// 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)
);
} else {
// Plaintext
$output = '<pre class="pluginoutput">' . preg_replace(
$output = preg_replace(
self::$txtPatterns,
self::$txtReplacements,
$this->view->escape($output)
) . '</pre>';
);
}
if (! $raw) {
$output = '<pre class="pluginoutput">' . $output . '</pre>';
}
$output = $this->fixLinks($output);
return $output;
Expand Down
Expand Up @@ -90,7 +90,7 @@ if (count($hosts) === 0) {
)
) ?>)</span>
<?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>
<?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($host->$col) ?></td>
Expand Down
Expand Up @@ -48,7 +48,7 @@ if (count($notifications) === 0) {
<?= $this->link()->host($notification->host_name, $notification->host_display_name) ?>
<?php endif ?>
<br>
<?= $this->escape($this->ellipsis($notification->notification_output, 10000)) ?>
<?= $this->pluginOutput($this->ellipsis($notification->notification_output, 10000), true) ?>
<br>
<?php if (! $this->contact): ?>
<small>
Expand Down
Expand Up @@ -82,7 +82,7 @@ if (count($services) === 0) {
)
) ?><br />
<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>
<?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($service->$col) ?></td>
Expand Down

0 comments on commit 604ef87

Please sign in to comment.