Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/13/2021 06:40:37 PM (3 years ago)
Author:
espellcaste
Message:

Sanitize all ORDER BY (ASC/DESC) values using the bp_esc_sql_order helper function where possible.

BuddyPress is not consistent on how it escapes ORDER BY (ASC/DESC) values provided by the developers/users. This commit improves that by using the bp_esc_sql_order helper function where possible.

Props imath

Fixes #8576

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/classes/class-bp-notifications-template.php

    r13108 r13147  
    176176
    177177        // Sort order direction.
    178         $orders = array( 'ASC', 'DESC' );
    179         if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders, true ) ) {
     178        if ( ! empty( $_GET['sort_order'] ) ) {
    180179            $r['sort_order'] = $_GET['sort_order'];
    181         } else {
    182             $r['sort_order'] = in_array( $r['sort_order'], $orders ) ? $r['sort_order'] : 'DESC';
    183180        }
    184181
     
    187184        $this->pag_page     = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
    188185        $this->pag_num      = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
     186        $this->sort_order   = bp_esc_sql_order( $r['sort_order'] );
    189187        $this->user_id      = $r['user_id'];
    190188        $this->is_new       = $r['is_new'];
    191189        $this->search_terms = $r['search_terms'];
    192190        $this->order_by     = $r['order_by'];
    193         $this->sort_order   = $r['sort_order'];
    194191        $this->query_vars   = array(
    195192            'id'                => $r['id'],
Note: See TracChangeset for help on using the changeset viewer.