Subject: | Bug with double_encode in URI::Encode |
Presently, URI::Encode will crash if you enabled the double_encode
parameter and try to encode a string containing a percent character:
perl -MURI::Encode -e 'print
URI::Encode->new({double_encode=>1})->encode("This is a %20 test")'
Use of uninitialized value $char in exists at
/usr/local/lib/perl5/site_perl/5.10.1/URI/Encode.pm line 149.
The reason for this is that you are failing to capture the percent
symbol in your regex in encode():
102 if ($double_encode) { $data =~
s{\%}{$self->_get_encoded_char($1)}gex; }
It should be this instead:
102 if ($double_encode) { $data =~
s{(\%)}{$self->_get_encoded_char($1)}gex; }
Regards,
-Dan