Make WordPress Core


Ignore:
Timestamp:
06/10/2020 05:58:07 PM (6 years ago)
Author:
desrosj
Message:

General: Backport several commits for release.

  • Embeds: Ensure that the title attribute is set correctly on embeds.
  • Editor: Prevent HTML decoding on by setting the proper editor context.
  • Formatting: Ensure that wp_validate_redirect() sanitizes a wider variety of characters.
  • Themes: Ensure a broken theme name is returned properly.
  • Administration: Add a new filter to extend set-screen-option.

Merges [47948-47951] to the 5.3 branch.
Props xknown, sstoqnov, vortfu, SergeyBiryukov, whyisjake.

Location:
branches/5.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

  • branches/5.3/src/wp-includes/embed.php

    r46164 r47959  
    798798        $title = ! empty( $data->title ) ? $data->title : '';
    799799
    800         $pattern        = '`<iframe[^>]*?title=(\\\\\'|\\\\"|[\'"])([^>]*?)\1`i';
    801         $has_title_attr = preg_match( $pattern, $result, $matches );
    802 
    803         if ( $has_title_attr && ! empty( $matches[2] ) ) {
    804                 $title = $matches[2];
     800        $pattern = '`<iframe([^>]*)>`i';
     801        if ( preg_match( $pattern, $result, $matches ) ) {
     802                $attrs = wp_kses_hair( $matches[1], wp_allowed_protocols() );
     803
     804                foreach ( $attrs as $attr => $item ) {
     805                        $lower_attr = strtolower( $attr );
     806                        if ( $lower_attr === $attr ) {
     807                                continue;
     808                        }
     809                        if ( ! isset( $attrs[ $lower_attr ] ) ) {
     810                                $attrs[ $lower_attr ] = $item;
     811                                unset( $attrs[ $attr ] );
     812                        }
     813                }
     814        }
     815
     816        if ( ! empty( $attrs['title']['value'] ) ) {
     817                $title = $attrs['title']['value'];
    805818        }
    806819
     
    821834        }
    822835
    823         if ( $has_title_attr ) {
    824                 // Remove the old title, $matches[1]: quote, $matches[2]: title attribute value.
    825                 $result = str_replace( ' title=' . $matches[1] . $matches[2] . $matches[1], '', $result );
    826         }
    827 
     836        if ( isset( $attrs['title'] ) ) {
     837                unset( $attrs['title'] );
     838                $attr_string = join( ' ', wp_list_pluck( $attrs, 'whole' ) );
     839                $result      = str_replace( $matches[0], '<iframe ' . trim( $attr_string ) . '>', $result );
     840        }
    828841        return str_ireplace( '<iframe ', sprintf( '<iframe title="%s" ', esc_attr( $title ) ), $result );
    829842}
Note: See TracChangeset for help on using the changeset viewer.