簡體   English   中英

我可以配置codeigniter以避免所有htmlentity嗎?

[英]Can I configure codeigniter to avoid all htmlentities?

我有一個巨大的codeigniter應用程序,具有很多形式和字段。 我需要避免用戶在任何輸入中輸入HTML代碼。 我知道我可以使用strip_tags這樣的功能逃脫它,也可以使用htmlentites對其進行逃避。

但我想知道是否有任何方法可以全局執行該操作,從而刪除或轉義插入整個應用程序任何輸入中的html代碼。

我修改了檢索結果的功能,過濾了html open和close標簽。 那就是我想要的東西。 拒絕顯示保存在數據庫中的html或javascript。

public function array_htmlentities(&$row){
        //return $row;
        foreach($row as &$value){
            if( is_array($value) || is_array($value) ){
                $value = $this->array_htmlentities($value);
            }elseif(is_string($value)){
                $json = json_decode($value);
                if( is_array($json) || is_array($json) ){
                    $value = json_encode($this->array_htmlentities($json));
                }else
                    $value = str_replace(array('<','>'), array('&lt;','&gt;'), $value);
                //$value = $value;
            }else
                $value = $value;
        }

        return $row;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM