Co-Authors-Plus icon indicating copy to clipboard operation
Co-Authors-Plus copied to clipboard

Biographical Info field on contributors profile is double-encoded

Open paulschreiber opened this issue 9 years ago • 7 comments

The Biographical Info (cap-description) field is double encoded. It generates HTML like this:

<label for="cap-description">Biographical Info</label></th><td>
<textarea style="width:300px;margin-bottom:6px;" name="cap-description">&amp;amp;Aaron is
here.</textarea>

In class-coauthors-guest-authors.php, in get_guest_author_fields(), we have this code:

array(
        'key'      => 'description',
        'label'    => __( 'Biographical Info', 'co-authors-plus' ),
        'group'    => 'about',
        'sanitize_function' => 'wp_filter_post_kses',
    ),

By calling wp_filter_post_kses instead of the default filter (sanitize_text_field), we end up with the double encoding.

paulschreiber avatar Apr 25 '16 19:04 paulschreiber

Here's a workaround:

foreach ( $fields as $index => $field ) {
    if ( 'description' === $field['key'] ) {
        $fields[ $index ]['sanitize_function'] = function( $s ) { return html_entity_decode( wp_filter_post_kses( $s ) ); };
    }
}```

paulschreiber avatar Aug 15 '16 21:08 paulschreiber

Could you clarify where you're seeing this please? I'm assuming it's on the guest author edit screen in the "Biographical Info" textarea. Here are the steps I've taken to reproduce:

  1. Create a new guest author
  2. Include this in the "Biographical Info" field: Aaron is here.
  3. Save the author
  4. Check the textarea
  5. Value is Aaron is here. as expected

philipjohn avatar Oct 22 '17 13:10 philipjohn

You missed the the ampersand in step 2. &Aaron is here.

This results in &amp;amp;Aaron is here instead of the expected &amp;Aaron is here.

paulschreiber avatar Nov 07 '17 13:11 paulschreiber

Ah that may have been a typo.

Here's what I'm typing in:

pre-save

Then I hit save and see

post-save

^ That's actually after saving twice (once to add the .).

philipjohn avatar Dec 19 '17 09:12 philipjohn

Yup. That's the bug.

paulschreiber avatar Dec 19 '17 13:12 paulschreiber

This results in &amp;amp;Aaron is here instead of the expected &amp;Aaron is here.

I thought the bug was the double amp as in that ^ example?

philipjohn avatar Dec 20 '17 12:12 philipjohn

My original example showed the HTML source of a double-encoded ampersand (&amp;amp;). Your example showed the rendered version (&amp;). We're seeing the same bug.

paulschreiber avatar Mar 16 '18 16:03 paulschreiber