Make WordPress Core

Changeset 44015


Ignore:
Timestamp:
12/12/2018 11:54:55 PM (8 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.0 branch.

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

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

    r33381 r44015  
    164164                        'lang' => true,
    165165                        'xml:lang' => true,
    166                 ),
    167                 'form' => array(
    168                         'action' => true,
    169                         'accept' => true,
    170                         'accept-charset' => true,
    171                         'enctype' => true,
    172                         'method' => true,
    173                         'name' => true,
    174                         'target' => true,
    175166                ),
    176167                'h1' => array(
     
    574565 *
    575566 * @since 3.5.0
     567 * @since 5.0.1 `form` removed as allowable HTML tag.
    576568 *
    577569 * @param string $context The context for which to retrieve tags. Allowed values are
     
    598590                case 'post':
    599591                        /** This filter is documented in wp-includes/kses.php */
    600                         return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
    601                         break;
     592                        $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
     593
     594                        // 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
     595                        if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
     596                                $tags = $allowedposttags;
     597
     598                                $tags['form'] = array(
     599                                        'action' => true,
     600                                        'accept' => true,
     601                                        'accept-charset' => true,
     602                                        'enctype' => true,
     603                                        'method' => true,
     604                                        'name' => true,
     605                                        'target' => true,
     606                                );
     607
     608                                /** This filter is documented in wp-includes/kses.php */
     609                                $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
     610                        }
     611
     612                        return $tags;
    602613                case 'user_description':
    603614                case 'pre_user_description':
Note: See TracChangeset for help on using the changeset viewer.