我一直在写一些Wordpress插件,而Wordpress在将魔术引号放在POST和GET数据上时遇到了一些问题。
具体来说,\ wp-includes \ load.php中的“ wp_magic_quotes”函数在wp-settings.php中被调用(大概在每个响应中)。即使我在PHP设置中关闭了魔术引号,此函数也会在数据中添加魔术引号。
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
* @access private
* @since 3.0.0
*/
function wp_magic_quotes() {
// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep( $_GET );
$_POST = stripslashes_deep( $_POST );
$_COOKIE = stripslashes_deep( $_COOKIE );
}
// Escape with wpdb.
$_GET = add_magic_quotes( $_GET );
$_POST = add_magic_quotes( $_POST );
$_COOKIE = add_magic_quotes( $_COOKIE );
$_SERVER = add_magic_quotes( $_SERVER );
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );
}
对我来说,只注释掉wp-settings.php中的wp_magic_quotes()调用安全吗?也就是说,它会对正常的Wordpress代码产生负面影响和/或开放某些利用媒介吗?如果是这样,除了修改WP代码之外,还有其他方法可以做到这一点(因此,我不必每次更新时都进行处理)吗?
wp_magic_quotes()
执行?我在wp-core中找不到执行。