Escaping user input from database necessary?

前端 未结 4 1470
逝去的感伤
逝去的感伤 2020-12-28 19:30

So I know about MySQL injection and always escape all my user input before putting it in my database. However I was wondering, imagine a user tries to submit a query to inje

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 20:14

    Does MySQL automatically escape their output or something like that, or should I escape in the second query as well?

    You need to escape in the second query as well. MySQL does not do any escaping on its output.

    Long answer: MySQL string escaping does not modify the string that is being inserted, it just makes sure it doesn't do any harm in the current query. Any SQL injection attempt still remains in the data.

提交回复
热议问题