CakePHPにはサニタイズ用のライブラリが用意されている。
利用するにはControllerのアクション内で
function xxxAction(){ App:import('Sanitize'); $text1 = $this->params['post']['text1']; $this->set("text1", Sanitize::stripAll($text1)); }として利用する。
App:import('Sanitize');
でライブラリを読み込み、
Sanitize::stripAll($text1)
で値をサニタイズしている。
clean( $data, $options = array ( ) )
escape( $string, $connection = 'default' )
formatColumns( $model )
html( $string, $remove = false )
paranoid( $string, $allowed = array ( ) )
stripAll( $str ) -- <script>, <style>, <img>タグ部分、空白文字(改行・タブなど)を除去
stripImages( $str ) -- <img>タグ部分を除去
stripScripts( $str ) -- <script>, <style>タグ部分を除去
stripTags( $str, $tag ) -- 第2引数で指定した名前のタグを除去
stripWhitespace( $str ) -- 空白文字(改行・タブなど)を除去
escape( $string, $connection = 'default' )
formatColumns( $model )
html( $string, $remove = false )
paranoid( $string, $allowed = array ( ) )
stripAll( $str ) -- <script>, <style>, <img>タグ部分、空白文字(改行・タブなど)を除去
stripImages( $str ) -- <img>タグ部分を除去
stripScripts( $str ) -- <script>, <style>タグ部分を除去
stripTags( $str, $tag ) -- 第2引数で指定した名前のタグを除去
stripWhitespace( $str ) -- 空白文字(改行・タブなど)を除去
データのサニタイズ(Data Sanitization) :: CakePHPによる作業の定石 :: マニュアル :: 1.2 Collection :: The Cookbook
http://book.cakephp.org/ja/view/153/Data-Sanitizat...
CakePHP: the rapid development php framework: Api : Sanitize
http://api.cakephp.org/class/sanitize
http://book.cakephp.org/ja/view/153/Data-Sanitizat...
CakePHP: the rapid development php framework: Api : Sanitize
http://api.cakephp.org/class/sanitize
このページへのコメント
yhUouZ I appreciate you sharing this blog. Awesome.
d7E7N8 <a href="http://rnppgumuepwi.com/">rnppgumuepwi</a>, [url=http://ofcyouykrhab.com/]ofcyouykrhab[/url], [link=http://qcpfmrcjmafo.com/]qcpfmrcjmafo[/link], http://hxfpshkuamxx.com/