Dima L.
Dima L.

Reputation: 3603

Yii2: How to stop yii2 from escaping $_POST variables?

Yii2 escapes all $_POST variables by adding additional slashes. How to stop that? (Magic quotes are disabled in PHP. Additional slashes are added by yii2, not by PHP)

Upvotes: 0

Views: 319

Answers (2)

Dima L.
Dima L.

Reputation: 3603

My bad. Yii doesn't change $_POST. And magic quotes are disabled.

The reason $_POST variables are escaped is because in my yii app I'm loading Wordpress wp-load.php and it is Wordpress who changed $_POST.

It is done in wp-settings.php by calling wp_magic_quotes() function. To avoid this I remember contents of $_GET, $_POST, $_REQUEST, $_COOKIE and $_SERVER, then load wp-load.php, cache all data I need from WP and revert back.

Thanks for your comments!

Upvotes: 2

arogachev
arogachev

Reputation: 33548

Yii2 doesn't change $_POST in any way because it's considered a bad practice. The problem is most likely with magic quotes, check it once again more accurately.

Related questions:

Upvotes: 0

Related Questions