CI uri_string() 需要验证吗?
我使用 codeigniter 作为我的框架,在控制器的顶部,我将添加一行代码,将 uri_string (用户请求的最后一个页面)发送到一个库,该库会将其发送到用户会话中,并可能最终发送到一个数据库。
我的问题是我是否需要验证这个 uri_string() 或者它是否安全?
I use codeigniter as my framework and in the top of my controllers I am going to add a line of code that will send the uri_string (the last page the user requested) to a library which will send it into the users session and possibly eventually into a database.
My question is whether or not I need to validate this uri_string() at all or whether it is safe as is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单的答案,如果有疑问请验证它。
您只需花很短的时间来编写代码,您就会高枕无忧。
另外,如果所有控制器都会发生这种情况,我建议您将函数调用添加到每个控制器的构造中,或者扩展核心控制器以将调用包含在其构造中。
Simple answer, if in doubt validate it.
For the short time it will take you to code it you will have peace of mind.
Also, if this is going to happen for all you controllers may I suggest that you either add the function call to the construct of each controller or extend the core controller to include the call in its construct.
请记住,
config.php
中的'permissed_uri_chars'
项将自动禁止任何包含不允许的字符的 URL。因此,只要您没有修改它以包含潜在的恶意字符,就应该没问题。来自 config.php 中的注释:但是,正如 Rooneyl 提到的,它可能不会无论如何,消毒不会伤害任何东西。
Keep in mind that the
'permitted_uri_chars'
item inconfig.php
will automatically prohibit any URL that contains non-permitted characters. So, as long as you haven't modified that to include potentially malicious characters, you should be ok. From the comments inconfig.php
:However, as Rooneyl mentions, it probably wouldn't hurt anything to sanitize it anyway.