Make WordPress Core


Ignore:
Timestamp:
10/17/2022 06:00:49 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Grouped backports to the 4.4 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.4 branch.
Props voldemortensen, johnbillion, paulkevan, peterwilsoncc, xknown, dd32, audrasjb, martinkrcho, davidbaumwald, tykoted, johnjamesjacoby, ehtis, matveb, talldanwp.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

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

    r34989 r54558  
    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 ) {
    … …  
    10121015                return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10131016        }
     1017
     1018        /**
     1019         * Sanitizes a 'relation' operator.
     1020         *
     1021         * @since 6.0.3
     1022         *
     1023         * @param string $relation Raw relation key from the query argument.
     1024         * @return string Sanitized relation ('AND' or 'OR').
     1025         */
     1026        public function sanitize_relation( $relation ) {
     1027                if ( 'OR' === strtoupper( $relation ) ) {
     1028                        return 'OR';
     1029                } else {
     1030                        return 'AND';
     1031                }
     1032        }
    10141033}
Note: See TracChangeset for help on using the changeset viewer.