mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-13 18:06:11 +00:00
fix #4778: fix boolean type check for json parameters over the api
if a real json boolean is sent via the api, $value is a JSON::PP::Boolean here instead of a string/scalar so we should validate that too the $value itself can be used normally in conditions like ---- if ($value) { ---- if the value is stringified, the result is either '1' or '0' so even if we have some explicit checks like that it should not make a problem Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
d4218592e5
commit
bc24aad316
@ -10,6 +10,7 @@ use Devel::Cycle -quiet; # todo: remove?
|
|||||||
use PVE::Tools qw(split_list $IPV6RE $IPV4RE);
|
use PVE::Tools qw(split_list $IPV6RE $IPV4RE);
|
||||||
use PVE::Exception qw(raise);
|
use PVE::Exception qw(raise);
|
||||||
use HTTP::Status qw(:constants);
|
use HTTP::Status qw(:constants);
|
||||||
|
use JSON;
|
||||||
use Net::IP qw(:PROC);
|
use Net::IP qw(:PROC);
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
@ -1040,6 +1041,9 @@ sub check_type {
|
|||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if ($vt) {
|
if ($vt) {
|
||||||
|
if ($type eq 'boolean' && JSON::is_bool($value)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
add_error($errors, $path, "type check ('$type') failed - got $vt");
|
add_error($errors, $path, "type check ('$type') failed - got $vt");
|
||||||
return undef;
|
return undef;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user