Since WordPress forces global input vars to get magic quoted, any access to them should pass through wp_unslash(). Likewise, any data data sent into a function that expects pre-slashed input should require an explicit wp_slash().
For example, wp_unslash() and wp_slash() could be enforced in situations like this:
$title = sanitize_text_field( wp_unslash( $_POST['title'] ) );
// ...
wp_insert_post( wp_slash( array(
'post_title' => $title,
) ) );
As a WordPress-Extra rule, this will help enforce a discipline of unslashing, sanitizing, and slashing when slashing is required (e.g. in wp_update_post(), update_post_meta(), etc). It's easy to forget and for slashing to sneak in or to get stripped out, \\o/ o/, yay.
#395 implements the sniff for wp_unslash()
Since WordPress forces global input vars to get magic quoted, any access to them should pass through
wp_unslash(). Likewise, any data data sent into a function that expects pre-slashed input should require an explicitwp_slash().For example,
wp_unslash()andwp_slash()could be enforced in situations like this:As a
WordPress-Extrarule, this will help enforce a discipline of unslashing, sanitizing, and slashing when slashing is required (e.g. inwp_update_post(),update_post_meta(), etc). It's easy to forget and for slashing to sneak in or to get stripped out,\\o/o/, yay.#395 implements the sniff for
wp_unslash()