Make WordPress Core


Ignore:
Timestamp:
10/17/2022 05:53:02 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Grouped backports to the 4.1 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,
  • Query: Validate relation in WP_Date_Query,
  • Widgets: Escape RSS error messages for display.

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

Location:
branches/4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/date.php

    r31396 r54552  
    142142    public function __construct( $date_query, $default_column = 'post_date' ) {
    143143
    144         if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    145             $this->relation = 'OR';
     144        if ( isset( $date_query['relation'] ) ) {
     145            $this->relation = $this->sanitize_relation( $date_query['relation'] );
    146146        } else {
    147147            $this->relation = 'AND';
     
    224224            $this->validate_date_values( $queries );
    225225        }
     226
     227        // Sanitize the relation parameter.
     228        $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    226229
    227230        foreach ( $queries as $key => $q ) {
     
    10031006        return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10041007    }
     1008
     1009    /**
     1010     * Sanitizes a 'relation' operator.
     1011     *
     1012     * @since 6.0.3
     1013     *
     1014     * @param string $relation Raw relation key from the query argument.
     1015     * @return string Sanitized relation ('AND' or 'OR').
     1016     */
     1017    public function sanitize_relation( $relation ) {
     1018        if ( 'OR' === strtoupper( $relation ) ) {
     1019            return 'OR';
     1020        } else {
     1021            return 'AND';
     1022        }
     1023    }
    10051024}
Note: See TracChangeset for help on using the changeset viewer.