gpt4 book ai didi

mysql - 理解 mysql_real_escape_string();

转载 作者:行者123 更新时间:2023-11-29 08:58:57 26 4
gpt4 key购买 nike

我不明白为什么 mysql_real_escape_string 需要转义换行符和回车符:

\n\r

使用 \n\r 的 SQL 中可能存在哪些安全漏洞?

UPDATE tbl SET field = 'text text text \n text text text \r text text' WHERE id = 1;

最佳答案

MySQL 不要求转义换行符。 manual page for the mysql_real_escape_string function of MySQL’s C API说:

Characters encoded are “\”, “'”, “"”, NUL (ASCII 0), “\n”, “\r”, and Control+Z. Strictly speaking, MySQL requires only that backslash and the quote character used to quote the string in the query be escaped. mysql_real_escape_string() quotes the other characters to make them easier to read in log files.

关于mysql - 理解 mysql_real_escape_string();,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9149461/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com