~ubuntu-branches/ubuntu/natty/perl/natty-updates

« back to all changes in this revision

Viewing changes to lib/CGI.pm

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2011-01-18 13:17:37 UTC
  • mfrom: (8.1.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110118131737-ul5ussvhhwb2n6ff
Tags: 5.10.1-17ubuntu1
* Merge from debian unstable.  Remaining changes: (LP: #704391)
  - debian/control: Change build dependency from libdb4.7-dev
    to libdb-dev, to minimize the db versions on the CDs.
  - debian/patches/fixes/h2ph-gcc-4.5.diff:
    + Fix h2ph header generation with GCC 4.5. (Closes: #599933)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1382
1382
sub multipart_init {
1383
1383
    my($self,@p) = self_or_default(@_);
1384
1384
    my($boundary,@other) = rearrange_header([BOUNDARY],@p);
1385
 
    $boundary = $boundary || '------- =_aaaaaaaaaa0';
 
1385
    if (!$boundary) {
 
1386
        $boundary = '------- =_';
 
1387
        my @chrs = ('0'..'9', 'A'..'Z', 'a'..'z');
 
1388
        for (1..17) {
 
1389
            $boundary .= $chrs[rand(scalar @chrs)];
 
1390
        }
 
1391
    }
 
1392
 
1386
1393
    $self->{'separator'} = "$CRLF--$boundary$CRLF";
1387
1394
    $self->{'final_separator'} = "$CRLF--$boundary--$CRLF";
1388
1395
    $type = SERVER_PUSH($boundary);
1467
1474
                            'EXPIRES','NPH','CHARSET',
1468
1475
                            'ATTACHMENT','P3P'],@p);
1469
1476
 
 
1477
    # CR escaping for values, per RFC 822
 
1478
    for my $header ($type,$status,$cookie,$target,$expires,$nph,$charset,$attachment,$p3p,@other) {
 
1479
        if (defined $header) {
 
1480
            # From RFC 822:
 
1481
            # Unfolding  is  accomplished  by regarding   CRLF   immediately
 
1482
            # followed  by  a  LWSP-char  as equivalent to the LWSP-char.
 
1483
            $header =~ s/$CRLF(\s)/$1/g;
 
1484
 
 
1485
            # All other uses of newlines are invalid input. 
 
1486
            if ($header =~ m/$CRLF|\015|\012/) {
 
1487
                # shorten very long values in the diagnostic
 
1488
                $header = substr($header,0,72).'...' if (length $header > 72);
 
1489
                die "Invalid header value contains a newline not followed by whitespace: $header";
 
1490
            }
 
1491
        } 
 
1492
   }
 
1493
 
1470
1494
    $nph     ||= $NPH;
1471
1495
 
1472
1496
    $type ||= 'text/html' unless defined($type);