【发布时间】:2023-03-06 11:14:01
【问题描述】:
因为我不知道在哪里搜索这个 - 也许这里有人可以帮助我。
我需要用户在 textarea 中添加类似的内容:
<script> var foo bar; </script>
<script type="text/javascript" src="http://foobar.de/mylist.js"></script>
但 Codeigniter 似乎有一个内置的代码注入保护 - 所以提交后我得到的只是:
[removed] var foo bar; [removed]
[removed][removed]
我该如何改变呢?我知道它不安全,但我需要解析出 URL。
作为替代,我需要一个 jQuery 函数来解析这个 URL。我对 regEx 不是很熟悉。 ^^
我的 PHP 解析器看起来像这样(从某处复制 ^^):
$reg_exUrl = '/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i';
if (preg_match($reg_exUrl, $_POST['code'], $matches)) {
$jsUrl = $matches[0];
}
【问题讨论】:
-
您可以尝试将
$config['global_xss_filtering'] = FALSE;设置为false。这个配置可以在 application/config/config.php 中找到 -
或者使用
$this->input->post('textareaName', false),这将在获取该文本区域的值时禁用 XSS 过滤。 -
谢谢。 Gavin 的解决方案会很好 - 所以我只能在这种情况下使用它 - 没有不安全的所有表格 - 但不幸的是它不起作用。 :(
标签: php jquery regex codeigniter code-injection