Add zero width space characters to plugin output where appropriate

This helps browsers to break lines if the plugin output is missing whitespaces.
Alternatively we could set word-break: break-all but that may produce ugly results.

refs #10820
This commit is contained in:
Eric Lippmann 2016-02-27 18:00:50 +01:00
parent 16cc5e333a
commit 1f7a4a170f
1 changed files with 8 additions and 0 deletions

View File

@ -51,6 +51,14 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
$isHtml = false;
}
$output = $this->fixLinks($output);
// Help browsers to break words in plugin output
$output = trim($output);
// Add space after comma where missing
$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
$output = preg_replace('/([^\s])([([])([^\s])/', '$1​$2$3', $output);
if (! $raw) {
if ($isHtml) {