我如何逃脱的MySQL是否正确? [英] How do I escape mysql properly?

查看:138
本文介绍了我如何逃脱的MySQL是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现,如果我写

select * from tbl where name like @foo

然后加富与价值 \ A (用户数据)的参数,它不会正确地转义。搞什么鬼!?!它希望 \\一个。我不禁觉得我开到一个SQL注入,即使我使用的参数。

Then add foo as a parameter with the value \a (user data) that it will not escape it correctly. What the hell!?! It wants \\a. I can't help but feel i'm open to a sql inject even though i am using parameters.

我如何逃脱的变量中的用户数据是否正确?我使用MySQL在C#中使用dapper.net

How do I escape the user data in variables correctly? I'm using mysql on C# with using dapper.net

推荐答案

对于像我陈述了在这个

.Replace(@"\", @"\\").Replace(@"_", @"\_").Replace(@"%", @"\%")

这篇关于我如何逃脱的MySQL是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆