diff --git a/core/classes/MantisFilter.class.php b/core/classes/MantisFilter.class.php index 5d089a0282..0e3fffaaab 100644 --- a/core/classes/MantisFilter.class.php +++ b/core/classes/MantisFilter.class.php @@ -49,6 +49,17 @@ abstract class MantisFilter { */ public $size = null; + /** + * Validate the filter input, returning true if input is + * valid, or returning false if invalid. Invalid inputs will + * be replaced with the filter's default value. + * @param multi Filter field input + * @return boolean Input valid (true) or invalid (false) + */ + public function validate( $p_filter_input ) { + return true; + } + /** * Build the SQL query elements 'join', 'where', and 'params' * as used by core/filter_api.php to create the primary filter diff --git a/core/filter_api.php b/core/filter_api.php index ddf0654448..be200dfbea 100644 --- a/core/filter_api.php +++ b/core/filter_api.php @@ -570,6 +570,10 @@ function filter_ensure_valid_filter( $p_filter_arr ) { $p_filter_arr[ $t_field_name ] = META_FILTER_ANY; } } + + if ( ! $t_filter_object->validate( $p_filter_arr[ $t_field_name ] ) ) { + $p_filter_arr[ $t_field_name ] = $t_filter_object->default; + } } $t_custom_fields = custom_field_get_ids();