Skip to content

Commit

Permalink
General: Backport several commits for release.
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
desrosj committed Jun 10, 2020
1 parent 8ad0d15 commit 20545be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -2831,8 +2831,11 @@ function edit_form_image_editor( $post ) {
<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong><?php
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
echo ': ' . __( 'Displayed on attachment pages.' );
} ?></label>
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
}

?>
</label>
<?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>

</div>
<?php
Expand Down
36 changes: 29 additions & 7 deletions src/wp-admin/includes/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,24 +620,46 @@ function set_screen_options() {
return;
break;
default:
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
/**
* Filters a screen option value before it is set.
*
* The filter can also be used to modify non-standard [items]_per_page
* settings. See the parent function for a full list of standard options.
*
* Returning false to the filter will skip saving the current option.
*
* @since 2.8.0
* @since 5.4.2 Only applied to options ending with '_page',
* or the 'layout_columns' option.
*
* @see set_screen_options()
*
* @param bool $keep Whether to save or skip saving the screen option value.
* Default false.
* @param string $option The option name.
* @param int $value The number of rows to use.
*/
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}

/**
* Filters a screen option value before it is set.
*
* The filter can also be used to modify non-standard [items]_per_page
* settings. See the parent function for a full list of standard options.
* The dynamic portion of the hook, `$option`, refers to the option name.
*
* Returning false to the filter will skip saving the current option.
*
* @since 2.8.0
* @since 5.4.2
*
* @see set_screen_options()
*
* @param bool|int $value Screen option value. Default false to skip.
* @param string $option The option name.
* @param int $value The number of rows to use.
* @param bool $keep Whether to save or skip saving the screen option value.
* Default false.
* @param string $option The option name.
* @param int $value The number of rows to use.
*/
$value = apply_filters( 'set-screen-option', false, $option, $value );
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );

if ( false === $value )
return;
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
</tr>
<?php foreach ( $broken_themes as $broken_theme ) : ?>
<tr>
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
<?php
if ( $can_delete ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ function wp_safe_redirect($location, $status = 302) {
* @return string redirect-sanitized URL
**/
function wp_validate_redirect($location, $default = '') {
$location = trim( $location, " \t\n\r\0\x08\x0B" );
$location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) );
// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
if ( substr($location, 0, 2) == '//' )
$location = 'http:' . $location;
Expand Down

0 comments on commit 20545be

Please sign in to comment.