libwww-perl / HTTP-Message

The HTTP-Message distribution contains classes useful for representing the messages passed in HTTP style communication.

Home Page:https://metacpan.org/pod/HTTP::Message

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug in HTTP::Message::decoded_content() [rt.cpan.org #86272]

oalders opened this issue · comments

Migrated from rt.cpan.org#86272 (status was 'open')

Requestors:

Attachments:

From p.gackiewicz@intertele.pl on 2013-06-20 08:17:48:

Hi.

I think there is a bug in decoded_content() function in this package.
In version 6.06, it evals such piece of code:

   if ($self->content_is_text || (my $is_xml = $self->content_is_xml)) {
       my $charset = lc(
           $opt{charset} ||
           $self->content_type_charset ||
           $opt{default_charset} ||
           $self->content_charset ||      # <=============
           "ISO-8859-1"
       );

...


but content_charset() calls decoded_content() again, creating circular
dependency. Evaled code silently dies then. If it is not logical error,
this code should be probably rewritten.

I found it trying to install CPAN XML::Twig code. It did not pass several
tests using LWP::Simple, loading simple HTML via file: url.

Simple patch attached, removing this call.

Regards,

-- 
Piotr Gackiewicz
Intertele S.A. - operator systemów ITL.PL i DOMENY.ITL.PL
al. T. Rejtana 10, 35-310 Rzeszów
TEL: +48 17 8507580, FAX: +48 17 8520275

http://www.itl.pl       - niezawodne serwery wirtualne
http://domeny.itl.pl    - tanie domeny internetowe
http://www.intertele.pl

From gaas@cpan.org on 2013-06-21 21:04:34:

I can't see anything wrong with the current code. The inner call to
decoded_content shouid never recurse further as it's called with charset =>
none.

Can you provide a small test case that demonstrates infinite recursion? I
wasn't able to reproduce any bad behaviour on my own.

Looking at the code, I also think that infinite recursion cannot happen.

Also, the bug author stated "Evaled code silently dies then". However, eval{} cannot trap infinite recursion (at least if use warnings "FATAL" is not set). The code would die with an out of memory error instead, or crash the computer.

Thanks @eserte. I will close this based on your assessment. :)