Make WordPress Core

Changeset 54557


Ignore:
Timestamp:
10/17/2022 05:59:19 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Grouped backports to the 4.3 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,
  • Customize: Escape blogname option in underscores templates,
  • Mail: Reset PHPMailer properties between use,
  • Query: Validate relation in WP_Date_Query,
  • Widgets: Escape RSS error messages for display.

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

Location:
branches/4.3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3

  • branches/4.3/src/wp-includes/comment.php

    r33223 r54557  
    25192519        }
    25202520
     2521        $filter_comment = false;
     2522        if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
     2523                $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
     2524        }
     2525
     2526        if ( $filter_comment ) {
     2527                add_filter( 'pre_comment_content', 'wp_filter_kses' );
     2528        }
     2529
    25212530        // Escape data pulled from DB.
    25222531        $comment = wp_slash($comment);
    … …  
    25282537
    25292538        $commentarr = wp_filter_comment( $commentarr );
     2539
     2540        if ( $filter_comment ) {
     2541                remove_filter( 'pre_comment_content', 'wp_filter_kses' );
     2542        }
    25302543
    25312544        // Now extract the merged array.
  • branches/4.3/src/wp-includes/date.php

    r32116 r54557  
    153153        public function __construct( $date_query, $default_column = 'post_date' ) {
    154154
    155                 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    156                         $this->relation = 'OR';
     155                if ( isset( $date_query['relation'] ) ) {
     156                        $this->relation = $this->sanitize_relation( $date_query['relation'] );
    157157                } else {
    158158                        $this->relation = 'AND';
    … …  
    233233                        $this->validate_date_values( $queries );
    234234                }
     235
     236                // Sanitize the relation parameter.
     237                $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    235238
    236239                foreach ( $queries as $key => $q ) {
    … …  
    10111014                return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10121015        }
     1016
     1017        /**
     1018         * Sanitizes a 'relation' operator.
     1019         *
     1020         * @since 6.0.3
     1021         *
     1022         * @param string $relation Raw relation key from the query argument.
     1023         * @return string Sanitized relation ('AND' or 'OR').
     1024         */
     1025        public function sanitize_relation( $relation ) {
     1026                if ( 'OR' === strtoupper( $relation ) ) {
     1027                        return 'OR';
     1028                } else {
     1029                        return 'AND';
     1030                }
     1031        }
    10131032}
  • branches/4.3/src/wp-includes/default-widgets.php

    r33942 r54557  
    11941194        if ( is_wp_error($rss) ) {
    11951195                if ( is_admin() || current_user_can('manage_options') )
    1196                         echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
     1196                        echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), esc_html( $rss->get_error_message() ) ) . '</p>';
    11971197                return;
    11981198        }
    … …  
    13041304
    13051305        if ( ! empty( $args['error'] ) ) {
    1306                 echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>';
     1306                echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), esc_html( $args['error'] ) ) . '</strong></p>';
    13071307        }
    13081308
  • branches/4.3/src/wp-includes/functions.php

    r46499 r54557  
    24492449        } else {
    24502450                $html = __( 'Are you sure you want to do this?' );
    2451                 if ( wp_get_referer() )
    2452                         $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
     2451                if ( wp_get_referer() ) {
     2452                        $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
     2453                        $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
     2454                        $html           .= '</p><p>';
     2455                        $html           .= sprintf(
     2456                                '<a href="%s">%s</a>',
     2457                                esc_url( $wp_http_referer ),
     2458                                __( 'Please try again.' )
     2459                        );
     2460                }
    24532461        }
    24542462
  • branches/4.3/src/wp-includes/media-template.php

    r33329 r54557  
    12531253                                <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
    12541254                        </div>
    1255                         <span class="browser-title"><?php bloginfo( 'name' ); ?></span>
     1255                        <span class="browser-title"><?php echo esc_js( get_bloginfo( 'name' ) ); ?></span>
    12561256                </div>
    12571257
  • branches/4.3/src/wp-includes/pluggable.php

    r47982 r54557  
    361361        $phpmailer->ClearCustomHeaders();
    362362        $phpmailer->ClearReplyTos();
     363        $phpmailer->Body    = '';
     364        $phpmailer->AltBody = '';
    363365
    364366        // From email and name
  • branches/4.3/src/wp-mail.php

    r39777 r54557  
    6060        wp_die( __('There doesn&#8217;t seem to be any new mail.') );
    6161}
     62
     63// Always run as an unauthenticated user.
     64wp_set_current_user( 0 );
    6265
    6366for ( $i = 1; $i <= $count; $i++ ) {
    … …  
    126129                                $author = sanitize_email($author);
    127130                                if ( is_email($author) ) {
    128                                         echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
    129131                                        $userdata = get_user_by('email', $author);
    130132                                        if ( ! empty( $userdata ) ) {
  • branches/4.3/src/wp-trackback.php

    r30662 r54557  
    1313        wp( array( 'tb' => '1' ) );
    1414}
     15
     16// Always run as an unauthenticated user.
     17wp_set_current_user( 0 );
    1518
    1619/**
Note: See TracChangeset for help on using the changeset viewer.