WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/12/2018 11:35:11 PM (3 years ago)
Author:
pento
Message:

KSES: Conditionally remove the <form> element from $allowedposttags.

To avoid backwards compatibility issues, <form> is re-added if a custom filter has added the <input> or <select> elements to $allowedposttags.

Merges [43994] to the 4.4 branch.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/kses.php

    r36430 r44003  
    183183            'lang' => true,
    184184            'xml:lang' => true,
    185         ),
    186         'form' => array(
    187             'action' => true,
    188             'accept' => true,
    189             'accept-charset' => true,
    190             'enctype' => true,
    191             'method' => true,
    192             'name' => true,
    193             'target' => true,
    194185        ),
    195186        'h1' => array(
     
    611602 *
    612603 * @since 3.5.0
     604 * @since 5.0.1 `form` removed as allowable HTML tag.
    613605 *
    614606 * @global array $allowedposttags
     
    640632        case 'post':
    641633            /** This filter is documented in wp-includes/kses.php */
    642             return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     634            $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     635
     636            // 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
     637            if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
     638                $tags = $allowedposttags;
     639
     640                $tags['form'] = array(
     641                    'action' => true,
     642                    'accept' => true,
     643                    'accept-charset' => true,
     644                    'enctype' => true,
     645                    'method' => true,
     646                    'name' => true,
     647                    'target' => true,
     648                );
     649
     650                /** This filter is documented in wp-includes/kses.php */
     651                $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
     652            }
     653
     654            return $tags;
    643655
    644656        case 'user_description':
Note: See TracChangeset for help on using the changeset viewer.