Make WordPress Core

Changeset 44293


Ignore:
Timestamp:
12/18/2018 04:45:54 PM (5 years ago)
Author:
desrosj
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 trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/kses.php

    r44207 r44293  
    187187            'lang'     => true,
    188188            'xml:lang' => true,
    189         ),
    190         'form'       => array(
    191             'action'         => true,
    192             'accept'         => true,
    193             'accept-charset' => true,
    194             'enctype'        => true,
    195             'method'         => true,
    196             'name'           => true,
    197             'target'         => true,
    198189        ),
    199190        'h1'         => array(
     
    825816 *
    826817 * @since 3.5.0
     818 * @since 5.0.1 `form` removed as allowable HTML tag.
    827819 *
    828820 * @global array $allowedposttags
     
    853845        case 'post':
    854846            /** This filter is documented in wp-includes/kses.php */
    855             return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     847            $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     848
     849            // 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
     850            if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
     851                $tags = $allowedposttags;
     852
     853                $tags['form'] = array(
     854                    'action' => true,
     855                    'accept' => true,
     856                    'accept-charset' => true,
     857                    'enctype' => true,
     858                    'method' => true,
     859                    'name' => true,
     860                    'target' => true,
     861                );
     862
     863                /** This filter is documented in wp-includes/kses.php */
     864                $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
     865            }
     866
     867            return $tags;
    856868
    857869        case 'user_description':
Note: See TracChangeset for help on using the changeset viewer.