Codeigniter 如何使用XSS筛选变量?
我正在使用带有友好URL(.htaccess)的Codeigniter 2.1.3 在控制器中:Codeigniter 如何使用XSS筛选变量?,codeigniter,codeigniter-2,Codeigniter,Codeigniter 2,我正在使用带有友好URL(.htaccess)的Codeigniter 2.1.3 在控制器中: public function confirm($key) { var_dump($this->input->get()); } 但是链接_http://site.com/confirm/12345 返回“boolean false” 如何在URL中启用查询字符串,或如何筛选$key 我的.htaccess: RewriteEngine on RewriteCond $1 !^(
public function confirm($key) {
var_dump($this->input->get());
}
但是链接_http://site.com/confirm/12345 返回“boolean false”
如何在URL中启用查询字符串,或如何筛选$key
我的.htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files|templates)
RewriteRule ^(.*)$ /index.php?/$1 [L]
您将收到
键
作为函数参数,因此可以执行以下操作:
public function confirm($key) {
echo $key;
}
http://site.com/confirm/12345
将回显12345
可以通过config.php
中的$config['allowed\u uri\u chars']
对其中的字符进行过滤
如果希望将其作为GET
参数接收,并希望对其执行XSS筛选,则需要
http://site.com/confirm?key=12345
和在控制器中
public function confirm() {
echo $this->input->get('key', TRUE); // true implies XSS filtering
}
第二种方法需要将
$config['enable_query_strings']
设置为TRUE
,感谢您的详细响应