Fix #2116 add space where line-breaking tag is removed

This commit is contained in:
Kijin Sung 2023-06-19 22:14:08 +09:00
parent 26f052925b
commit 558df8e42f
2 changed files with 9 additions and 4 deletions

View file

@ -459,6 +459,7 @@ class CommentItem extends BaseObject
$content = $this->get('content'); $content = $this->get('content');
} }
$content = preg_replace('!(</p|</div|<br)!i', ' $1', $content);
$content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content))));
if($strlen) if($strlen)
{ {
@ -490,9 +491,10 @@ class CommentItem extends BaseObject
$content = $this->get('content'); $content = $this->get('content');
} }
$content = preg_replace('!(</p|</div|<br)!i', ' $1', $content);
$content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content))));
if($strlen) if($strlen)
{ {
$content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content))));
$content = cut_str($content, $strlen, '...'); $content = cut_str($content, $strlen, '...');
} }
return escape($content); return escape($content);
@ -564,7 +566,9 @@ class CommentItem extends BaseObject
function getSummary($str_size = 50, $tail = '...') function getSummary($str_size = 50, $tail = '...')
{ {
// Remove tags // Remove tags
$content = strip_tags($this->getContent(false, false)); $content = $this->getContent(false, false);
$content = preg_replace('!(</p|</div|<br)!i', ' $1', $content);
$content = strip_tags($content);
// Convert temporarily html entity for truncate // Convert temporarily html entity for truncate
$content = html_entity_decode($content, ENT_QUOTES); $content = html_entity_decode($content, ENT_QUOTES);

View file

@ -625,7 +625,7 @@ class DocumentItem extends BaseObject
return lang('msg_is_secret'); return lang('msg_is_secret');
} }
$content = $this->get('content'); $content = preg_replace('!(</p|</div|<br)!i', ' $1', $this->get('content'));
$content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content))));
if($strlen) if($strlen)
{ {
@ -647,7 +647,7 @@ class DocumentItem extends BaseObject
return lang('msg_is_secret'); return lang('msg_is_secret');
} }
$content = $this->get('content'); $content = preg_replace('!(</p|</div|<br)!i', ' $1', $this->get('content'));
$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
if($strlen) if($strlen)
@ -790,6 +790,7 @@ class DocumentItem extends BaseObject
{ {
// Remove tags // Remove tags
$content = $this->getContent(false, false); $content = $this->getContent(false, false);
$content = preg_replace('!(</p|</div|<br)!i', ' $1', $content);
$content = strip_tags(preg_replace('!<(style|script)\b.+?</\\1>!is', '', $content)); $content = strip_tags(preg_replace('!<(style|script)\b.+?</\\1>!is', '', $content));
// Convert temporarily html entity for truncate // Convert temporarily html entity for truncate