admin管理员组文章数量:1429061
I know when I want to save data in database, I must sanitize data but what about following case which is a simple comparison. Should I sanitize?
if ( ! isset( $_GET['page'] ) ) {
return;
}
if ( 'google' === $_GET['page'] ) {
wp_redirect( '' );
exit;
}
if ( 'facebook' === $_GET['page'] ) {
wp_redirect( '' );
exit;
}
I know when I want to save data in database, I must sanitize data but what about following case which is a simple comparison. Should I sanitize?
if ( ! isset( $_GET['page'] ) ) {
return;
}
if ( 'google' === $_GET['page'] ) {
wp_redirect( 'https://google' );
exit;
}
if ( 'facebook' === $_GET['page'] ) {
wp_redirect( 'https://facebook' );
exit;
}
Share
Improve this question
asked May 27, 2019 at 3:08
user3631047user3631047
1731 silver badge7 bronze badges
1 Answer
Reset to default 1No, it's not necessary to sanitise in this case.
If you were redirecting to the value directly, or outputting it in some way, you would definitely need to, but since you're just comparing its value against a white list (essentially) no sanitising or escaping is necessary.
本文标签: pluginsSanitize GET variable when comparing
版权声明:本文标题:plugins - Sanitize $_GET variable when comparing 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745461951a2659362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论