Exclude scripts and styles from document summary

관리자 권한으로 문서에 스크립트나 스타일을 넣어 놓은 경우
getSummary()에서 해당 내용이 표시되는 문제 수정

<style>CSS</style> 구조로 입력되므로 strip_tags() 사용시
앞뒤의 태그만 삭제되고 중간에 있는 CSS가 그대로 노출될 수 있음.
This commit is contained in:
Kijin Sung 2020-11-30 21:39:34 +09:00
parent 6b3d201539
commit e2c7a3eefe

View file

@ -765,7 +765,8 @@ class documentItem extends BaseObject
function getSummary($str_size = 50, $tail = '...')
{
// Remove tags
$content = strip_tags($this->getContent(false, false));
$content = $this->getContent(false, false);
$content = strip_tags(preg_replace('!<(style|script)\b.+?</\\1>!is', '', $content));
// Convert temporarily html entity for truncate
$content = html_entity_decode($content, ENT_QUOTES);