Skip to content

Commit

Permalink
Numeric fields shouldn’t accept floats
Browse files Browse the repository at this point in the history
Fixes #16133
  • Loading branch information
vboctor committed Oct 22, 2017
1 parent d310496 commit bc40253
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/custom_field_api.php
Expand Up @@ -1088,7 +1088,9 @@ function custom_field_validate( $p_field_id, $p_value ) {
if( $t_length == 0 ) {
break;
}
$t_valid &= is_numeric( $p_value );

# is_numeric() accepts floats, so also check that it is a whole integer
$t_valid &= is_numeric( $p_value ) && (int)$p_value == (float)$p_value;

# Check the length of the number
$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
Expand Down

0 comments on commit bc40253

Please sign in to comment.