Merge pull request #3708 from Icinga/fix/html-entities-in-plugin-output-3707

Don't escape html entities in plugin output twice
This commit is contained in:
Johannes Meyer 2019-04-05 08:05:52 +02:00 committed by GitHub
commit affed19536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */ /* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
use Icinga\Web\Dom\DomNodeIterator; use Icinga\Web\Dom\DomNodeIterator;
use Icinga\Web\View;
use Icinga\Module\Monitoring\Web\Helper\PluginOutputPurifier; use Icinga\Module\Monitoring\Web\Helper\PluginOutputPurifier;
/** /**
@ -115,7 +116,8 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
$output = preg_replace( $output = preg_replace(
self::$txtPatterns, self::$txtPatterns,
self::$txtReplacements, self::$txtReplacements,
$this->view->escape($output) // Not using the view here to escape this. The view sets `double_encode` to true
htmlspecialchars($output, ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5, View::CHARSET, false)
); );
$isHtml = false; $isHtml = false;
} }

View File

@ -65,6 +65,14 @@ class PluginOutputTest extends BaseTestCase
); );
} }
public function testOutputWithHtmlEntities()
{
$this->checkOutput(
'foo & bar',
'foo & bar'
);
}
public function testSimpleHtmlOutput() public function testSimpleHtmlOutput()
{ {
/** @noinspection HtmlUnknownAttribute */ /** @noinspection HtmlUnknownAttribute */