1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 09:44:28 +01:00

Don't truncate inside an HTML comment!

This commit is contained in:
Macil Tech 2013-01-14 19:11:55 -06:00
parent 36af0af624
commit 263ecfe5ce

View File

@ -155,6 +155,11 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) {
$max_lines = $config['body_truncate']; $max_lines = $config['body_truncate'];
if ($max_chars === false) if ($max_chars === false)
$max_chars = $config['body_truncate_char']; $max_chars = $config['body_truncate_char'];
// We don't want to risk truncating in the middle of an HTML comment.
// It's easiest just to remove them all first.
$body = preg_replace('/<!--.*?-->/s', '', $body);
$original_body = $body; $original_body = $body;
$lines = substr_count($body, '<br/>'); $lines = substr_count($body, '<br/>');