Make WordPress Core

Changeset 47969 for branches/4.1


Ignore:
Timestamp:
06/10/2020 06:32:29 PM (6 years ago)
Author:
whyisjake
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 [47947-47951] to the 4.0 branch.
Props xknown, sstoqnov, vortfu, SergeyBiryukov, whyisjake.

Location:
branches/4.1
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-admin/includes/media.php

    r40466 r47969  
    27222722        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
    27232723                echo ': ' . __( 'Displayed on attachment pages.' );
    2724         } ?></label>
    2725         <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
     2724        }
     2725
     2726        ?>
     2727        </label>
     2728        <?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>
    27262729
    27272730        </div>
  • branches/4.1/src/wp-admin/includes/misc.php

    r30200 r47969  
    406406                                break;
    407407                        default:
     408                                if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
     409                                        /**
     410                                         * Filters a screen option value before it is set.
     411                                         *
     412                                         * The filter can also be used to modify non-standard [items]_per_page
     413                                         * settings. See the parent function for a full list of standard options.
     414                                         *
     415                                         * Returning false to the filter will skip saving the current option.
     416                                         *
     417                                         * @since 2.8.0
     418                                         * @since 5.4.2 Only applied to options ending with '_page',
     419                                         *              or the 'layout_columns' option.
     420                                         *
     421                                         * @see set_screen_options()
     422                                         *
     423                                         * @param bool   $keep   Whether to save or skip saving the screen option value.
     424                                         *                       Default false.
     425                                         * @param string $option The option name.
     426                                         * @param int    $value  The number of rows to use.
     427                                         */
     428                                        $value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     429                                }
    408430
    409431                                /**
    410432                                 * Filter a screen option value before it is set.
    411433                                 *
    412                                  * The filter can also be used to modify non-standard [items]_per_page
    413                                  * settings. See the parent function for a full list of standard options.
     434                                 * The dynamic portion of the hook, `$option`, refers to the option name.
    414435                                 *
    415436                                 * Returning false to the filter will skip saving the current option.
    416437                                 *
    417                                  * @since 2.8.0
     438                                 * @since 5.4.2
    418439                                 *
    419440                                 * @see set_screen_options()
    420441                                 *
    421                                  * @param bool|int $value  Screen option value. Default false to skip.
    422                                  * @param string   $option The option name.
    423                                  * @param int      $value  The number of rows to use.
     442                                 * @param bool   $keep   Whether to save or skip saving the screen option value.
     443                                 *                       Default false.
     444                                 * @param string $option The option name.
     445                                 * @param int    $value  The number of rows to use.
    424446                                 */
    425                                 $value = apply_filters( 'set-screen-option', false, $option, $value );
     447                                $value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
    426448
    427449                                if ( false === $value )
  • branches/4.1/src/wp-admin/themes.php

    r30794 r47969  
    279279        <?php foreach ( $broken_themes as $broken_theme ) : ?>
    280280                <tr>
    281                         <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
     281                        <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
    282282                        <td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
    283283                        <?php
  • branches/4.1/src/wp-includes/pluggable.php

    r46501 r47969  
    11961196 **/
    11971197function wp_sanitize_redirect($location) {
    1198         $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()]|i', '', $location);
     1198        $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()@]|i', '', $location);
    11991199        $location = wp_kses_no_null($location);
    12001200
     
    12501250 **/
    12511251function wp_validate_redirect($location, $default = '') {
    1252         $location = trim( $location, " \t\n\r\0\x08\x0B" );
     1252        $location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) );
    12531253        // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
    12541254        if ( substr($location, 0, 2) == '//' )
  • branches/4.1/tests/phpunit/tests/formatting/redirect.php

    r40190 r47969  
    3131                $this->assertEquals('http://[2606:2800:220:6d:26bf:1447:aa7]/', wp_sanitize_redirect('http://[2606:2800:220:6d:26bf:1447:aa7]/'));
    3232                $this->assertEquals('http://example.com/search.php?search=(amistillhere)', wp_sanitize_redirect('http://example.com/search.php?search=(amistillhere)'));
     33                $this->assertEquals('http://example.com/@username', wp_sanitize_redirect('http://example.com/@username'));
    3334        }
    3435
Note: See TracChangeset for help on using the changeset viewer.