清理 MySQL 用户参数
当用户的输入将被插入到 MySQL 查询中时,用户输入中应该替换哪些危险字符? 我知道引号、双引号、\r 和 \n。 还有其他吗?
(我无法选择使用接受参数的智能连接器,因此我必须自己构建查询,这将用多种编程语言实现,包括一些晦涩难懂的语言,因此解决方案例如 PHP 中的 mysql_real_escape_string
无效)
What are the dangerous characters that should be replaced in user input when the users' input will be inserted in a MySQL query? I know about quotes, double quotes, \r and \n. Are there others?
(I don't have the option of using a smart connector that accepts parameters so I have to build the query myself and this will be implemented in multiple programming languages, including some obscure ones so solutions such as mysql_real_escape_string
in PHP are not valid)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
mysql_real_escape_string() 来自 mysql。 com 文档:
mysql_real_escape_string()
> 具有字符集感知能力 addslashes_dont_call_it_a_comeback.html" rel="nofollow noreferrer">http://cognifty.com/blog.entry/id=6/addslashes_dont_call_it_a_comeback.html:
mysql_real_escape_string() from mysql.com docs:
mysql_real_escape_string() is character set aware, so replicating all its abilities (especially against multi-byte attack issues) is not a small amount of work.
From http://cognifty.com/blog.entry/id=6/addslashes_dont_call_it_a_comeback.html:
您需要支持哪些语言? 使用语言的内置清理比编写自己的清理要好得多。
编辑:查看 php.net 上的
mysql_real_escape_string
:What languages do you need to support? It is much better to use a language's built-in sanitization than to write your own.
Edit: Looking at
mysql_real_escape_string
on php.net: