Subject: | Misuse of utf8::decode |
utf8::decode is supposed to work only on strings. But it was buggy. It used to do nothing for
references. Perl 5.15.7 fixed this, but it seem Net::Whois::Raw was relying on the bug:
$ perl5.15.7 -Ilib -MNet::Whois::Raw -e 'use Data::Dumper; warn Dumper scalar
Net::Whois::Raw::whois("iweufhweufhweufh.ru",undef,"QRY_ALL")'
$VAR1 = 'ARRAY(0x841df0)';
This line in the whois sub is to blame:
utf8::decode( $res_text ); # Perl whyly loss utf8 flag
It seems that when QRY_ALL is specified $res_text is actually an array reference, so the array
gets flattened. If I comment out that line, all the tests still pass.
So changing it to
utf8::decode( $res_text ) unless ref $res_text;
will make it work the same way in 5.15.7 as it does in earlier versions; but I wonder whether
it was not already buggy. If utf8::decode is necessary for a flat string, would it not also be
necessary for the string inside the array ref? I do not know enough about how this module
works to answer that question.
BTW, QRY_ALL seems to be entirely untested.
This bug is the ultimate cause of bug #74340.