Grouped backports to the 4.0 branch.

- Posts, Post types: Apply KSES to post-by-email content,
- General: Validate host on "Are you sure?" screen,
- Posts, Post types: Remove emails from post-by-email logs,
- Pings/trackbacks: Apply KSES to all trackbacks,
- Comments: Apply kses when editing comments,
- Mail: Reset PHPMailer properties between use,
- Widgets: Escape RSS error messages for display.

Merges [54521], [54522], [54523], [54525], [54527], [54529], [54541] to the 4.0 branch.
Props voldemortensen, johnbillion, paulkevan, peterwilsoncc, xknown, dd32, audrasjb, martinkrcho, davidbaumwald, tykoted, matveb, talldanwp.

Built from https://develop.svn.wordpress.org/branches/4.0@54551


git-svn-id: http://core.svn.wordpress.org/branches/4.0@54106 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-10-17 17:50:16 +00:00
parent 5563191eb6
commit 314c192e35
6 changed files with 34 additions and 5 deletions

View File

@ -1916,6 +1916,16 @@ function wp_update_comment($commentarr) {
if ( empty( $comment ) ) {
return 0;
}
$filter_comment = false;
if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
$filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
}
if ( $filter_comment ) {
add_filter( 'pre_comment_content', 'wp_filter_kses' );
}
// Escape data pulled from DB.
$comment = wp_slash($comment);
@ -1926,6 +1936,10 @@ function wp_update_comment($commentarr) {
$commentarr = wp_filter_comment( $commentarr );
if ( $filter_comment ) {
remove_filter( 'pre_comment_content', 'wp_filter_kses' );
}
// Now extract the merged array.
$data = wp_unslash( $commentarr );

View File

@ -1018,7 +1018,7 @@ function wp_widget_rss_output( $rss, $args = array() ) {
if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') )
echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), esc_html( $rss->get_error_message() ) ) . '</p>';
return;
}
@ -1128,7 +1128,7 @@ function wp_widget_rss_form( $args, $inputs = null ) {
$args['show_date'] = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date'];
if ( ! empty( $args['error'] ) ) {
echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>';
echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), esc_html( $args['error'] ) ) . '</strong></p>';
}
if ( $inputs['url'] ) :

View File

@ -2436,8 +2436,16 @@ function wp_nonce_ays( $action ) {
$html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url( $redirect_to ) );
} else {
$html = __( 'Are you sure you want to do this?' );
if ( wp_get_referer() )
$html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
if ( wp_get_referer() ) {
$wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
$wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
$html .= '</p><p>';
$html .= sprintf(
'<a href="%s">%s</a>',
esc_url( $wp_http_referer ),
__( 'Please try again.' )
);
}
}
wp_die( $html, $title, array('response' => 403) );

View File

@ -350,6 +350,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
$phpmailer->ClearAttachments();
$phpmailer->ClearCustomHeaders();
$phpmailer->ClearReplyTos();
$phpmailer->Body = '';
$phpmailer->AltBody = '';
// From email and name
// If we don't have a name from the input headers

View File

@ -60,6 +60,9 @@ if( 0 === $count ) {
wp_die( __('There doesn&#8217;t seem to be any new mail.') );
}
// Always run as an unauthenticated user.
wp_set_current_user( 0 );
for ( $i = 1; $i <= $count; $i++ ) {
$message = $pop3->get($i);
@ -125,7 +128,6 @@ for ( $i = 1; $i <= $count; $i++ ) {
$author = trim($line);
$author = sanitize_email($author);
if ( is_email($author) ) {
echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
$userdata = get_user_by('email', $author);
if ( ! empty( $userdata ) ) {
$post_author = $userdata->ID;

View File

@ -13,6 +13,9 @@ if (empty($wp)) {
wp( array( 'tb' => '1' ) );
}
// Always run as an unauthenticated user.
wp_set_current_user( 0 );
/**
* Response to a trackback.
*