Although magic_quotes are turned off still escaped

2019-06-22 12:43发布

I disabled magic_quotes in my php.ini.

But I still get escaped strings in my form.

Note: I'm running this in a theme in Wordpress.

1条回答
我想做一个坏孩纸
2楼-- · 2019-06-22 13:00

I actually already figured this out, just want to leave my solution here in case other people might find it useful:

Wordpress automatically escapes all request variables. If magic quotes are turned off, they strip the slashes first, but add them again afterwards.

wp-settings.php code piece:

// 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);

Source: http://www.wptextads.com/blog/2007/05/19/gpc-magic-quotes-in-wordpress-is-compulsory/

查看更多
登录 后发表回答