Skip to content

Commit

Permalink
gpc_get_int() don't remove spaces in middle of string
Browse files Browse the repository at this point in the history
Keep using preg_match() instead of calling filter_var() as the latter's
interpretation of what an integer is is too strict for our purposes
(e.g. `01` is not considered as an integeger).

Remove unnecessary capturing group in number validation regex.

Fixes #35525
  • Loading branch information
dregad committed Mar 1, 2025
1 parent fb768e5 commit 3c52527
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/gpc_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ function gpc_get_int( $p_var_name, $p_default = null ) {
error_parameters( $p_var_name );
trigger_error( ERROR_GPC_ARRAY_UNEXPECTED, ERROR );
}
$t_val = str_replace( ' ', '', trim( (string)$t_result ) );
if( !preg_match( '/^-?([0-9])*$/', $t_val ) ) {
$t_val = trim( (string)$t_result );
if( !preg_match( '/^-?[0-9]*$/', $t_val ) ) {
error_parameters( $p_var_name );
trigger_error( ERROR_GPC_NOT_NUMBER, ERROR );
}
Expand Down

0 comments on commit 3c52527

Please sign in to comment.