diff --git a/config/func.inc.php b/config/func.inc.php index 571cceb74..3044ac8d4 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -416,9 +416,18 @@ // style 태그 제거 $content = preg_replace("!!is", '', $content); + // XSS 사용을 위한 이벤트 제거 + $content = preg_replace_callback("!<([a-z]+)(.*?)>!is", removeJSEvent, $content); + return $content; } + function removeJSEvent($matches) { + $tag = strtolower($matches[1]); + if($tag == "a" && preg_match('/href=("|\'?)javascript:/i',$matches[2])) $matches[0] = preg_replace('/href=("|\'?)javascript:/i','href=$1_javascript:', $matches[0]); + return preg_replace('/on([a-z]+)=/i','_on$1=',$matches[0]); + } + // hexa값을 RGB로 변환 if(!function_exists('hexrgb')) { function hexrgb($hexstr) {