Hello all.

I found in the perl debugger

         'header' => Email::Simple::Header=HASH(0x11fba88)
            'headers' => ARRAY(0x12451b8)
               0  'Content-type'
               1  'application/octet-stream; 
name="s018308e70c.key.txt"'
               2  'Content-Disposition'
               3  'attachment; filename="s018308e70c.key.txt"'
               4  'Content-ID'
               5  '<[EMAIL PROTECTED]>'
               6  'Content-Transfer-Encoding'
               7  'base64 '
            'mycrlf' => "\cM\cJ"

that the last element in the headers array seems to sometimes have 
a
white space. That base64 is going to turn into a decode function 
that
will fail. I modified the function

sub _header_to_list {
  my ($self, $head, $mycrlf) = @_;

  my @headers;

  while ($$head =~ m/\G(.+?)$crlf/go) {
    local $_ = $1;
    if (s/^\s+// or not /^([^:]+):\s*(.*)/) {
      # This is a continuation line. We fold it onto the end of
      # the previous header.
      next if [EMAIL PROTECTED];  # Well, that sucks.  We're continuing 
nothing?

      $headers[-1] .= $headers[-1] ? " $_" : $_;
    } else {
        push @headers, $1, $2;
    }
  }

  #
  # This is a hack. Seems like there is trailing white space
  # on the end of the last header value, ie, $header[$#header].
  # [EMAIL PROTECTED] 20070312
  #
  $headers[$#headers] =~ s/\s+$//;

  return [EMAIL PROTECTED];
}

and added the
$headers[$#headers] =~ s/\s+$//;
right before the return. This seems to have fixed the problem.

Is the root cause the line
$headers[-1] .= $headers[-1] ? " $_" : $_;
in the code? Ideas?

thx,
don


Reply via email to