Skip to content

Using sanitize_text_field can break site_token #114

@mahowell

Description

@mahowell

If, for example, the sequence %B2 exists somewhere in the site_token, sanitize_text_field( $_POST['site_token'] ) will strip it out breaking the site_token.

In class-syndication-wp-rest-client.php:
update_post_meta( $site_ID, 'syn_site_token', push_syndicate_encrypt( sanitize_text_field( $_POST['site_token'] ) ) );

Not sure the best way to sanitize this field or if it even needs to be sanitized, but my current workaround:

function syndication_sanitize( $filtered, $str ) {
    if ( is_admin() && ! empty( $_POST ) && 'syn_site' === get_post_type() ) {
        return $str;
    } else {
        return $filtered;
    }
}
add_filter( 'sanitize_text_field', 'syndication_sanitize', 10, 2 );

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions