Skip to content

Commit 20545be

Browse files
committed
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 5.0 branch. Props xknown, sstoqnov, vortfu, SergeyBiryukov, whyisjake. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@47964 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8ad0d15 commit 20545be

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

src/wp-admin/includes/media.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,8 +2831,11 @@ function edit_form_image_editor( $post ) {
28312831
<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong><?php
28322832
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
28332833
echo ': ' . __( 'Displayed on attachment pages.' );
2834-
} ?></label>
2835-
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
2834+
}
2835+
2836+
?>
2837+
</label>
2838+
<?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>
28362839

28372840
</div>
28382841
<?php

src/wp-admin/includes/misc.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,24 +620,46 @@ function set_screen_options() {
620620
return;
621621
break;
622622
default:
623+
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
624+
/**
625+
* Filters a screen option value before it is set.
626+
*
627+
* The filter can also be used to modify non-standard [items]_per_page
628+
* settings. See the parent function for a full list of standard options.
629+
*
630+
* Returning false to the filter will skip saving the current option.
631+
*
632+
* @since 2.8.0
633+
* @since 5.4.2 Only applied to options ending with '_page',
634+
* or the 'layout_columns' option.
635+
*
636+
* @see set_screen_options()
637+
*
638+
* @param bool $keep Whether to save or skip saving the screen option value.
639+
* Default false.
640+
* @param string $option The option name.
641+
* @param int $value The number of rows to use.
642+
*/
643+
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
644+
}
623645

624646
/**
625647
* Filters a screen option value before it is set.
626648
*
627-
* The filter can also be used to modify non-standard [items]_per_page
628-
* settings. See the parent function for a full list of standard options.
649+
* The dynamic portion of the hook, `$option`, refers to the option name.
629650
*
630651
* Returning false to the filter will skip saving the current option.
631652
*
632-
* @since 2.8.0
653+
* @since 5.4.2
633654
*
634655
* @see set_screen_options()
635656
*
636-
* @param bool|int $value Screen option value. Default false to skip.
637-
* @param string $option The option name.
638-
* @param int $value The number of rows to use.
657+
* @param bool $keep Whether to save or skip saving the screen option value.
658+
* Default false.
659+
* @param string $option The option name.
660+
* @param int $value The number of rows to use.
639661
*/
640-
$value = apply_filters( 'set-screen-option', false, $option, $value );
662+
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
641663

642664
if ( false === $value )
643665
return;

src/wp-admin/themes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
</tr>
338338
<?php foreach ( $broken_themes as $broken_theme ) : ?>
339339
<tr>
340-
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
340+
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
341341
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
342342
<?php
343343
if ( $can_delete ) {

src/wp-includes/pluggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ function wp_safe_redirect($location, $status = 302) {
13271327
* @return string redirect-sanitized URL
13281328
**/
13291329
function wp_validate_redirect($location, $default = '') {
1330-
$location = trim( $location, " \t\n\r\0\x08\x0B" );
1330+
$location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) );
13311331
// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
13321332
if ( substr($location, 0, 2) == '//' )
13331333
$location = 'http:' . $location;

0 commit comments

Comments
 (0)