WordPress.org

Make WordPress Core

Changeset 34090


Ignore:
Timestamp:
09/12/15 21:05:14 (21 months ago)
Author:
boonebgorges
Message:

Use stricter sanitization for meta query clause keys.

By forcing all clause keys to be strings, we make it possible to use strict
comparison when validating values of 'orderby' as passed to WP_Query. This
eliminates situations where the presence of numeric clause keys could result
in an improperly validated 'orderby' value.

Props nikolov.tmw.
Fixes #32937.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-meta-query.php

    r33761 r34090  
    549549        $clause['cast'] = $meta_type; 
    550550 
    551         // Fallback for clause keys is the table alias. 
    552         if ( ! $clause_key ) { 
     551        // Fallback for clause keys is the table alias. Key must be a string. 
     552        if ( is_int( $clause_key ) || ! $clause_key ) { 
    553553            $clause_key = $clause['alias']; 
    554554        } 
  • trunk/src/wp-includes/query.php

    r34089 r34090  
    22812281        } 
    22822282 
    2283         if ( ! in_array( $orderby, $allowed_keys ) ) { 
     2283        if ( ! in_array( $orderby, $allowed_keys, true ) ) { 
    22842284            return false; 
    22852285        } 
Note: See TracChangeset for help on using the changeset viewer.