Improve BBCode:toPlaintext

- Fix issue where matching literal square brackets were removed with their content
- Fix issue where content without line feeds between BBCode tags would end up compacted in plain text
- Update extr calls to BBCode::toPlaintext in api
This commit is contained in:
Hypolite Petovan 2019-08-04 10:22:23 -04:00
parent a0f77e1800
commit c3e3e83a52
2 changed files with 3 additions and 6 deletions

View file

@ -357,10 +357,7 @@ class BBCode extends BaseObject
*/
public static function toPlaintext($text, $keep_urls = true)
{
$naked_text = preg_replace('/\[.+?\]/','', $text);
if (!$keep_urls) {
$naked_text = preg_replace('#https?\://[^\s<]+[^\s\.\)]#i', '', $naked_text);
}
$naked_text = HTML::toPlaintext(BBCode::convert($text, false, 0, true), 0, !$keep_urls);
return $naked_text;
}