Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/17/2021 10:34:57 PM (5 years ago)
Author:
dcavins
Message:

Limit orderby values in BP_Invitation.

Ensure that passed orderby value matches a
verified database column name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0/src/bp-core/classes/class-bp-invitation.php

    r12547 r13070  
    131131         */
    132132        public $accepted;
     133
     134        /**
     135         * Columns in the invitations table.
     136         *
     137         * @since 9.0.0
     138         * @access public
     139         * @var array
     140         */
     141        public static $columns = array(
     142                'id',
     143                'user_id',
     144                'inviter_id',
     145                'invitee_email',
     146                'class',
     147                'item_id',
     148                'secondary_item_id',
     149                'type',
     150                'content',
     151                'date_modified',
     152                'invite_sent',
     153                'accepted'
     154        );
    133155
    134156        /** Public Methods ****************************************************/
     
    474496                // Order by.
    475497                if ( ! empty( $args['order_by'] ) ) {
    476                         $order_by               = implode( ', ', (array) $args['order_by'] );
    477                         $conditions['order_by'] = "{$order_by}";
     498                        $order_by_clean = array();
     499                        foreach ( (array) $args['order_by'] as $key => $value ) {
     500                                if ( in_array( $value, self::$columns, true ) ) {
     501                                        $order_by_clean[] = $value;
     502                                }
     503                        }
     504                        if ( ! empty( $order_by_clean ) ) {
     505                                $order_by               = implode( ', ', $order_by_clean );
     506                                $conditions['order_by'] = "{$order_by}";
     507                        }
    478508                }
    479509
Note: See TracChangeset for help on using the changeset viewer.