WordPress.org

Make WordPress Core

Changeset 43997


Ignore:
Timestamp:
12/12/2018 11:16:14 PM (12 months 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.9 branch.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

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

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