From e2c7a3eefe884fc392071a2056842f2e75f70925 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 30 Nov 2020 21:39:34 +0900 Subject: [PATCH] Exclude scripts and styles from document summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 관리자 권한으로 문서에 스크립트나 스타일을 넣어 놓은 경우 getSummary()에서 해당 내용이 표시되는 문제 수정 구조로 입력되므로 strip_tags() 사용시 앞뒤의 태그만 삭제되고 중간에 있는 CSS가 그대로 노출될 수 있음. --- modules/document/document.item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 18e2f596e..14e019d00 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -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.+?!is', '', $content)); // Convert temporarily html entity for truncate $content = html_entity_decode($content, ENT_QUOTES);