开发者

Although magic_quotes are turned off still escaped strings?

开发者 https://www.devze.com 2023-01-17 17:30 出处:网络
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 Wordpre开发者_Go百科ss.I actually already figured this out, just want to leav

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 Wordpre开发者_Go百科ss.


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消