Merge pull request #9584 from open-sausages/pulls/4.5/plain-method-for-chinese-character

BUG Tweak DBHTMLText::Plain to avoid treating some chinese characters…
This commit is contained in:
Andre Kiste 2020-07-09 23:13:12 +12:00 committed by GitHub
commit 0ed340faa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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' =>[
'充美好实的一天',
'充美好实的一天'
]
];
}