Make WordPress Core

Changeset 44019


Ignore:
Timestamp:
12/13/2018 12:05:32 AM (7 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 3.7 branch.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

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

    r33389 r44019  
    159159            'lang' => true,
    160160            'xml:lang' => true,
    161         ),
    162         'form' => array(
    163             'action' => true,
    164             'accept' => true,
    165             'accept-charset' => true,
    166             'enctype' => true,
    167             'method' => true,
    168             'name' => true,
    169             'target' => true,
    170161        ),
    171162        'h1' => array(
     
    565556 *
    566557 * @since 3.5.0
     558 * @since 5.0.1 `form` removed as allowable HTML tag.
    567559 *
    568560 * @param string $context The context for which to retrieve tags. Allowed values are
     
    578570    switch ( $context ) {
    579571        case 'post':
    580             return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     572            $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     573
     574            // 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
     575            if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
     576                $tags = $allowedposttags;
     577
     578                $tags['form'] = array(
     579                    'action' => true,
     580                    'accept' => true,
     581                    'accept-charset' => true,
     582                    'enctype' => true,
     583                    'method' => true,
     584                    'name' => true,
     585                    'target' => true,
     586                );
     587
     588                /** This filter is documented in wp-includes/kses.php */
     589                $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
     590            }
     591
     592            return $tags;
    581593            break;
    582594        case 'user_description':
Note: See TracChangeset for help on using the changeset viewer.