~ubuntu-branches/ubuntu/lucid/libwww-perl/lucid-security

« back to all changes in this revision

Viewing changes to lib/HTTP/Message.pm

  • Committer: Bazaar Package Importer
  • Author(s): Iulian Udrea
  • Date: 2009-08-14 20:59:42 UTC
  • mfrom: (1.4.1 upstream) (12.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090814205942-ie58edrkoz4saquo
Tags: 5.831-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
use strict;
4
4
use vars qw($VERSION $AUTOLOAD);
5
 
$VERSION = "5.828";
 
5
$VERSION = "5.831";
6
6
 
7
7
require HTTP::Headers;
8
8
require Carp;
260
260
                $self->eof;
261
261
            }, "tagname, attr, self"],
262
262
            report_tags => [qw(meta)],
 
263
            utf8_mode => 1,
263
264
        );
264
265
        $p->parse($$cref);
265
266
        return $charset if $charset;
311
312
                }
312
313
                elsif ($ce eq "x-bzip2") {
313
314
                    require Compress::Bzip2;
 
315
                    my $i = Compress::Bzip2::bzinflateInit() or
 
316
                        die "Can't init bzip2 inflater: $Compress::Bzip2::bzerrno";
314
317
                    unless ($content_ref_iscopy) {
315
 
                        # memBunzip is documented to destroy its buffer argument
 
318
                        # the $i->bzinflate method is documented to destroy its
 
319
                        # buffer argument
316
320
                        my $copy = $$content_ref;
317
321
                        $content_ref = \$copy;
318
322
                        $content_ref_iscopy++;
319
323
                    }
320
 
                    $content_ref = \Compress::Bzip2::memBunzip($$content_ref);
321
 
                    die "Can't bunzip content" unless defined $$content_ref;
 
324
                    # TODO: operate on the ref when rt#48124 is fixed
 
325
                    my ($out, $status) = $i->bzinflate($$content_ref);
 
326
                    my $bzerr = "";
 
327
                    # TODO: drop $out definedness part when rt#48124 is fixed
 
328
                    if (!defined($out) &&
 
329
                        $status != Compress::Bzip2::BZ_STREAM_END()) {
 
330
                        if ($status == Compress::Bzip2::BZ_OK()) {
 
331
                            $self->push_header("Client-Warning" =>
 
332
                               "Content might be truncated; incomplete bzip2 stream");
 
333
                        }
 
334
                        else {
 
335
                            # something went bad, can't trust $out any more
 
336
                            $out = undef;
 
337
                            # $bzerrno has more info than $i->bzerror or $status
 
338
                            $bzerr = ": $Compress::Bzip2::bzerrno";
 
339
                        }
 
340
                    }
 
341
                    die "Can't bunzip content$bzerr" unless defined $out;
 
342
                    $content_ref = \$out;
 
343
                    $content_ref_iscopy++;
322
344
                }
323
345
                elsif ($ce eq "deflate") {
324
346
                    require Compress::Zlib;
471
493
        }
472
494
        elsif ($encoding eq "x-bzip2") {
473
495
            require Compress::Bzip2;
474
 
            $content = Compress::Bzip2::memGzip($content);
 
496
            my $d = Compress::Bzip2::bzdeflateInit() or
 
497
                die "Can't init bzip2 deflater: $Compress::Bzip2::bzerrno";
 
498
            ($content, my $status) = $d->bzdeflate($content);
 
499
            die "Can't bzip content: $Compress::Bzip2::bzerrno"
 
500
                unless $status == Compress::Bzip2::BZ_OK();
 
501
            (my $rest, $status) = $d->bzclose;
 
502
            die "Can't bzip content: $Compress::Bzip2::bzerrno"
 
503
                unless $status == Compress::Bzip2::BZ_OK();
 
504
            $content .= $rest if defined $rest;
475
505
        }
476
506
        elsif ($encoding eq "rot13") {  # for the fun of it
477
507
            $content =~ tr/A-Za-z/N-ZA-Mn-za-m/;