BUG Tweak DBHTMLText::Plain to avoid treating some chinese characters as line breaks.

This commit is contained in:
Maxime Rainville 2020-07-09 13:33:43 +12:00
parent 8eab6c6549
commit b780c4f504
2 changed files with 5 additions and 1 deletions

View File

@ -228,7 +228,7 @@ class DBHTMLText extends DBText
$text = strip_tags($text);
// Implode >3 consecutive linebreaks into 2
$text = preg_replace('~(\R){2,}~', "\n\n", $text);
$text = preg_replace('~(\R){2,}~u', "\n\n", $text);
// Decode HTML entities back to plain text
return trim(Convert::xml2raw($text));

View File

@ -265,6 +265,10 @@ class DBHTMLTextTest extends SapphireTest
[
'<p>Collapses</p><p></p><p>Excessive<br/><br /><br>Newlines</p>',
"Collapses\n\nExcessive\n\nNewlines",
],
'Unicode character that could be confused for a line break' =>[
'充美好实的一天',
'充美好实的一天'
]
];
}