Make WordPress Core


Ignore:
Timestamp:
10/17/2022 06:08:00 PM (2 years ago)
Author:
audrasjb
Message:

Grouped backports to the 5.2 branch.

  • Editor: Bump @wordpress packages for the branch,
  • Media: Refactor search by filename within the admin,
  • REST API: Lockdown post parameter of the terms endpoint,
  • Customize: Escape blogname option in underscores templates,
  • Query: Validate relation in WP_Date_Query,
  • 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,
  • Mail: Reset PHPMailer properties between use,
  • Comments: Apply kses when editing comments,
  • Widgets: Escape RSS error messages for display.

Merges [54521-54530] to the 5.2 branch.
Props audrasjb, costdev, cu121, dd32, davidbaumwald, ehtis, johnbillion, johnjamesjacoby, martinkrcho, matveb, oztaser, paulkevan, peterwilsoncc, ravipatel, SergeyBiryukov, talldanwp, timothyblynjacobs, tykoted, voldemortensen, vortfu, xknown.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r42877 r54563  
    146146     */
    147147    public function __construct( $date_query, $default_column = 'post_date' ) {
    148         if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    149             $this->relation = 'OR';
     148        if ( isset( $date_query['relation'] ) ) {
     149            $this->relation = $this->sanitize_relation( $date_query['relation'] );
    150150        } else {
    151151            $this->relation = 'AND';
     
    225225            $this->validate_date_values( $queries );
    226226        }
     227
     228        // Sanitize the relation parameter.
     229        $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    227230
    228231        foreach ( $queries as $key => $q ) {
     
    10211024        return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10221025    }
     1026
     1027    /**
     1028     * Sanitizes a 'relation' operator.
     1029     *
     1030     * @since 6.0.3
     1031     *
     1032     * @param string $relation Raw relation key from the query argument.
     1033     * @return string Sanitized relation ('AND' or 'OR').
     1034     */
     1035    public function sanitize_relation( $relation ) {
     1036        if ( 'OR' === strtoupper( $relation ) ) {
     1037            return 'OR';
     1038        } else {
     1039            return 'AND';
     1040        }
     1041    }
    10231042}
Note: See TracChangeset for help on using the changeset viewer.