I've added a function check_against_regexp to util.php3 that allows user-supplied input to be matched (using preg_match) against one or more regular expressions.
For example, the following cleanup rule checks to make sure the user supplied id is comprised entirely of alphanumeric characters or the _ character. If the input doesn't pass the check, it becomes a NULL value.
var $cleanup_rules = array('id' => array
('function' => 'check_against_regexp',
'extra_args' => array('/^[a-z0-9_]*$/i')));
A few common regular expressions can be referenced in the extra arguments array by name. These are currently:
- 'alphanumeric' => '/^[a-z0-9]*$/i'
- 'email' => '/^[0-9A-Za-z_\-]+[@][0-9A-Za-z_\-]+ ([.][0-9A-Za-z]+)([.][A-Za-z]{2,3}){0,1}$/x'
Files modified
- util.php3