Closed bluhm closed 1 year ago
HI,
could you please open an issue and provide a test case? While I understand that accessing the ref w/o checking that it exists is bad, I don't see how it modifies the hash under test:
perl -de0
DB<1> $hash = {blah => 1}
DB<2> use Data::Dumper
DB<3> p Dumper($hash)
$VAR1 = {
'blah' => 1
};
DB<4> $hash_ref = ref $hash->{"kuk"};
DB<5> p Dumper($hash)
$VAR1 = {
'blah' => 1
};
Thanks a lot in advance!
My fix is wrong. Thanks @stigmh for your analysis.
The new hash ref check in Data::Validate::Struct version 0.11 unconditionally accesses the fields in the hash to be validated. If the key does not exists, the config tree given to validate() changes when reading the reference type of the non nonexistent value. Only do the type check if the subtree exists. This restores old behavior of 0.10 and tests of my OSPF::LSDB module pass again.