Changeset 32190 for branches/3.9/src/wp-includes/formatting.php
- Timestamp:
- 04/20/2015 12:35:07 PM (11 years ago)
- File:
-
- 1 edited
-
branches/3.9/src/wp-includes/formatting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9/src/wp-includes/formatting.php
r30452 r32190 1179 1179 1180 1180 /** 1181 * Ensures a string is a valid SQL order by clause. 1182 * 1183 * Accepts one or more columns, with or without ASC/DESC, and also accepts 1184 * RAND(). 1181 * Ensures a string is a valid SQL 'order by' clause. 1182 * 1183 * Accepts one or more columns, with or without a sort order (ASC / DESC). 1184 * e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc. 1185 * 1186 * Also accepts 'RAND()'. 1185 1187 * 1186 1188 * @since 2.5.1 1187 1189 * 1188 * @param string $orderby Order by string to be checked.1189 * @return string|bool Returns the order by clause if it is a match, false otherwise.1190 */ 1191 function sanitize_sql_orderby( $orderby ) {1192 preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);1193 if ( !$obmatches )1194 return false;1195 return $orderby;1190 * @param string $orderby Order by clause to be validated. 1191 * @return string|bool Returns $orderby if valid, false otherwise. 1192 */ 1193 function sanitize_sql_orderby( $orderby ) { 1194 if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) { 1195 return $orderby; 1196 } 1197 return false; 1196 1198 } 1197 1199
Note: See TracChangeset
for help on using the changeset viewer.