PHP关于mysql_real_escape_string的很奇怪的bug
2011-03-27 12:20
651 查看
长话短说,mysql_query串的安全问题是众所周知的,对拼入sql串的数据字符串要做mysql_real_escape_string(或mysql_escape_string),这些没有问题,可是,但是,在大名鼎鼎的php上面,有这样一个‘bug’,有时候你发现你escape后的串,输入到了数据库,调了好久,一步步跟踪数据的变化,后来发现在$_POST[]中变量就已经被escape了,于是你再调mysql_real_escape_string,就会多作一次变换,而结果就是:数据串'xxx"' => 'xxx/"' => 'xxx///"',结果可想而知,于是我查了一下php.ini,关键字(escape),发现这样一个选项:
; - magic_quotes_gpc = Off [Performance]
; Input data is no longer escaped with slashes so that it can be sent into
; SQL databases without further manipulation. Instead, you should use the
; database vendor specific escape string function on each input element you
; wish to send to a database.
很蛋疼。
; - magic_quotes_gpc = Off [Performance]
; Input data is no longer escaped with slashes so that it can be sent into
; SQL databases without further manipulation. Instead, you should use the
; database vendor specific escape string function on each input element you
; wish to send to a database.
很蛋疼。
相关文章推荐
- 关于PHP mysql_real_escape_string() 函数对数据库的保护作用 ,预防数据库被攻击的一种手段
- PHP - mysql_real_escape_string()与mysql_escape_string()
- PHP mysql_real_escape_string() 函数
- PHP mysql_real_escape_string() 函数
- php mysql_real_escape_string() 函数
- PHP - mysql_real_escape_string()与mysql_escape_string() 的区别
- PHP mysql_real_escape_string() 函数防SQL注入
- PHP 5.4 已废弃 magic_quotes_gpc,PHP安全转义函数详解(addslashes 、htmlspecialchars、htmlentities、mysql_real_escape_string、strip_tags)
- PHP mysql_real_escape_string() 函数
- PHP防SQL注入不要再用addslashes和mysql_real_escape_string
- PHP mysql_real_escape_string的使用陷阱
- php 函数积累记录 -- mysql_real_escape_string
- PHP 安全手册 第五条 输出转义 最好的MYSQL 转义函数 mysql_real_escape_string
- 一个登陆安全的函数PHP mysql_real_escape_string() 函数
- php中防注入函数addslashes() ,mysql_real_escape_string() 和mysql_escape_string() 的区别
- PHP mysql_real_escape_string() 函数
- php-addslashes, mysql_escape_string, mysql_real_escepe_string
- [乐意黎转载]PHP mysql_real_escape_string() 函数
- PHP mysql_real_escape_string() 函数预防数据库攻击
- php中mysql_real_escape_string+sprintf防止sql注入