Merge branch 'bugfix/preserve-character-after-comma-in-plugin-output-11728'

fixes #11728
This commit is contained in:
Eric Lippmann 2016-06-02 17:49:28 +02:00
commit 934fb34c06
2 changed files with 26 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
// Help browsers to break words in plugin output
$output = trim($output);
// Add space after comma where missing
$output = preg_replace('/,[^\s]/', ', ', $output);
$output = preg_replace('/,(?=[^\s])/', ', ', $output);
// Add zero width space after ')', ']', ':', '.', '_' and '-' if not surrounded by whitespaces
$output = preg_replace('/([^\s])([\\)\\]:._-])([^\s])/', '$1$2​$3', $output);
// Add zero width space before '(' and '[' if not surrounded by whitespaces

View File

@ -0,0 +1,25 @@
<?php
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
namespace Tests\Icinga\Module\Monitoring\Regression;
require_once __DIR__ . '/../../../application/views/helpers/PluginOutput.php';
use Icinga\Test\BaseTestCase;
use Zend_View_Helper_PluginOutput;
/**
* Regression-Test for bug #11728
*
* Plugin output renderer must preserve the first character after a comma.
*
* @see https://dev.icinga.org/issues/11728
*/
class Bug11728Test extends BaseTestCase
{
public function testWhetherPluginOutputPreservesCharacterAfterComma()
{
$helper = new Zend_View_Helper_PluginOutput();
$this->assertTrue(strpos($helper->pluginOutput('<a href="#">A,BC', true), 'BC') !== false);
}
}