避免 SQL 注入
如果我确保在查询中只使用字母数字字符,我应该不会受到任何 SQL 注入,对吗?
If I make sure only alpha-numerical characters are used in queries I should be free of any SQL injections, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SQL 注入预防 CheatSheet
要点:
SQL Injection Prevention CheatSheet
Bullet points:
仅使用字母数字字符编写有用的查询非常困难。使用参数化查询,不要寻找非快捷方式。
It's pretty difficult to write a useful query with only alpha-numeric characters. Use paramterized queries, don't look for a non-shortcut shortcut.
从技术上讲,这可能是正确的,因为它会阻止使用 - 或类似的技巧。然而,如今大多数平台都有更强大的方法来正确转义输入并防止其以意想不到的方式影响数据库。
Technically, that's probably correct, since it would block using -- or similar trickery. Most platforms these days have much more robust methods for properly escaping input and keeping it from affecting the database in unintended ways, however.