Changeset 32191 for branches/3.8/src/wp-includes/formatting.php
- Timestamp:
- 04/20/2015 12:37:57 PM (11 years ago)
- File:
-
- 1 edited
-
branches/3.8/src/wp-includes/formatting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.8/src/wp-includes/formatting.php
r30455 r32191 1119 1119 1120 1120 /** 1121 * Ensures a string is a valid SQL order by clause. 1122 * 1123 * Accepts one or more columns, with or without ASC/DESC, and also accepts 1124 * RAND(). 1121 * Ensures a string is a valid SQL 'order by' clause. 1122 * 1123 * Accepts one or more columns, with or without a sort order (ASC / DESC). 1124 * e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc. 1125 * 1126 * Also accepts 'RAND()'. 1125 1127 * 1126 1128 * @since 2.5.1 1127 1129 * 1128 * @param string $orderby Order by string to be checked.1129 * @return string|bool Returns the order by clause if it is a match, false otherwise.1130 */ 1131 function sanitize_sql_orderby( $orderby ) {1132 preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);1133 if ( !$obmatches )1134 return false;1135 return $orderby;1130 * @param string $orderby Order by clause to be validated. 1131 * @return string|bool Returns $orderby if valid, false otherwise. 1132 */ 1133 function sanitize_sql_orderby( $orderby ) { 1134 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 ) ) { 1135 return $orderby; 1136 } 1137 return false; 1136 1138 } 1137 1139
Note: See TracChangeset
for help on using the changeset viewer.