Make WordPress Core


Ignore:
Timestamp:
04/03/2008 03:06:01 AM (18 years ago)
Author:
markjaquith
Message:

Fix gallery shortcode orderby param for all SQL setups. Sanitize orderby. fixes #6476 for 2.5.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/wp-includes/formatting.php

    r7520 r7593  
    365365
    366366    return $title;
     367}
     368
     369// ensures a string is a valid SQL order by clause like: post_name ASC, ID DESC
     370// accepts one or more columns, with or without ASC/DESC, and also accepts RAND()
     371function sanitize_sql_orderby( $orderby ){
     372    preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);
     373    if ( !$obmatches )
     374        return false;
     375    return $orderby;
    367376}
    368377
Note: See TracChangeset for help on using the changeset viewer.