Make WordPress Core


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

Grouped backports to the 4.8 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,
  • Media: Refactor search by filename within the admin,
  • Pings/trackbacks: Apply KSES to all trackbacks,
  • Comments: Apply kses when editing comments,
  • Customize: Escape blogname option in underscores templates,
  • REST API: Lockdown post parameter of the terms endpoint,
  • Mail: Reset PHPMailer properties between use,
  • Query: Validate relation in WP_Date_Query,
  • Widgets: Escape RSS error messages for display.

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

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

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

    r39672 r54568  
    152152         */
    153153        public function __construct( $date_query, $default_column = 'post_date' ) {
    154                 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    155                         $this->relation = 'OR';
     154                if ( isset( $date_query['relation'] ) ) {
     155                        $this->relation = $this->sanitize_relation( $date_query['relation'] );
    156156                } else {
    157157                        $this->relation = 'AND';
    … …  
    232232                        $this->validate_date_values( $queries );
    233233                }
     234
     235                // Sanitize the relation parameter.
     236                $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    234237
    235238                foreach ( $queries as $key => $q ) {
    … …  
    10181021                return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10191022        }
     1023
     1024        /**
     1025         * Sanitizes a 'relation' operator.
     1026         *
     1027         * @since 6.0.3
     1028         *
     1029         * @param string $relation Raw relation key from the query argument.
     1030         * @return string Sanitized relation ('AND' or 'OR').
     1031         */
     1032        public function sanitize_relation( $relation ) {
     1033                if ( 'OR' === strtoupper( $relation ) ) {
     1034                        return 'OR';
     1035                } else {
     1036                        return 'AND';
     1037                }
     1038        }
    10201039}
Note: See TracChangeset for help on using the changeset viewer.