Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
--Apple-Mail-30--196590585 Content-Disposition: inline; filename=moriyama1.gif Content-Transfer-Encoding: base64 Content-Type: application/applefile; name="moriyama1.gif" AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAJAAAAMgAAAAoAAAADAAAAPAAAAA1HSU +ZmcHJ2 dwEAbW9yaXlhbWExLmdpZg== --Apple-Mail-30--196590585 Content-Disposition: inline; filename=moriyama1.gif Content-Transfer-Encoding: base64 Content-Type: image/gif; x-mac-creator=70727677; x-unix-mode=0644; x-mac-type=47494666; name="moriyama1.gif" R0lGODlhZABnALMAAPDv79LR0FJQT66trJGQjykoJ9zb2m9ubebl5aCfnbu5uMfFxIKBfw +EBAQIC AgAAACH5BAA [etc...] --Apple-Mail-30--196590585--
Here the parser chokes on the image. Since I have never seen any of the other images with two headers like this, can I assume it is because the mail software is formatting it strangly? If so how can I get the real image which starts with the Content-Type: image/gif ?
My code looks like this. (I know this is not pretty, and I'm open to sugegstions to make it nice, but the thing I really care abotu is just getting the image now)
foreach my $part (@parts) { next unless defined $part->head; my $head_string = $part->head->as_string; next unless $head_string =~ m!text/plain|alternative|image|oct +et|gif!i; my $body_string = $part->bodyhandle->as_string; my @part = ($head_string, $body_string); push(@text, \@part) if $head_string =~ m!text/plain|altern +ative!i; push(@images, \@part) if $head_string =~ m!image|octet|gif +!i; } $thing->{'images'} = \@images; $thing->{'text'} = \@text; return($thing); }
If I don't have the next statement in there, it dies when the parser failes on thje "application/applefile" header. If I put in the next statement, it skips that header, but also skips the images.
Is there anything I can do about this without having to ditch MIME::Parser (I really really really want it to work with MIME::Parser)
K
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MIME::Parser and applefile
by Corion (Patriarch) on Jul 07, 2003 at 17:07 UTC | |
|
Re: MIME::Parser and applefile
by Thelonius (Priest) on Jul 07, 2003 at 20:09 UTC | |
by Anonymous Monk on Jul 08, 2003 at 14:12 UTC | |
|
Re: MIME::Parser and applefile
by demerphq (Chancellor) on Jul 07, 2003 at 17:52 UTC | |
|
Re: MIME::Parser and applefile
by bobn (Chaplain) on Jul 07, 2003 at 20:16 UTC |