Changeset 4302 for sandbox

Show
Ignore:
Timestamp:
06/19/2008 02:40:20 PM (3 months ago)
Author:
zero
Message:

XSS 시도를 차단하기 위한 글 내용의 event handling 코드를 무효화 시키도록 기능 추가

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • sandbox/config/func.inc.php

    r4290 r4302  
    417417        $content = preg_replace("!<style(.*?)<\/style>!is", '', $content); 
    418418 
     419        // XSS 사용을 위한 이벤트 제거 
     420        $content = preg_replace_callback("!<([a-z]+)(.*?)>!is", removeJSEvent, $content); 
     421 
    419422        return $content; 
     423    } 
     424 
     425    function removeJSEvent($matches) { 
     426        $tag = strtolower($matches[1]); 
     427        if($tag == "a" && preg_match('/href=("|\'?)javascript:/i',$matches[2])) $matches[0] = preg_replace('/href=("|\'?)javascript:/i','href=$1_javascript:', $matches[0]); 
     428        return preg_replace('/on([a-z]+)=/i','_on$1=',$matches[0]); 
    420429    } 
    421430