Hi all,

I have a problem with "MIME::Parser" package

The problem is that when the email has an attachment with a brackets ( or ) in filename the package stores the file with wrong name in system directory.Let me show the example:

THE CODE IS THAT:

# -------------------------------------------------------------------- +-------------------- use MIME::Parser; $tmp_dir = "/tmp"; $tmp_dir = $tmp_dir.'/'."$$" while -d $tmp_dir; $message_source = 'From root@domainname.localdomain Mon Nov 27 19 +:42:47 2006 Return-Path: <root@domainname.localdomain> Received: from domainname.localdomain (domainname.localdomain [127.0.0 +.1]) by domainname.localdomain (8.13.7/8.13.7) with ESMTP id kARHgljo02 +5235 for <root@domainname.localdomain>; Mon, 27 Nov 2006 19:42:47 +0200 Received: (from root@localhost) by domainname.localdomain (8.13.7/8.13.7/Submit) id kARHglZA025234 for root@localhost; Mon, 27 Nov 2006 19:42:47 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C7070D.D848F424" Subject: email subject Date: Mon, 13 Nov 2006 10:26:06 -0000 Message-ID: <E27D9DB1DAC80A4EBA2761F3F12F5ACCEDCE37@zuk35exm60.ds.ttt. +com> From: test@test.com To: test@tete.com This is a multi-part message in MIME format. ------_=_NextPart_001_01C7070D.D848F424 Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C7070D.D848F424" ------_=_NextPart_002_01C7070D.D848F424 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable DM for is attached (56287) ------_=_NextPart_002_01C7070D.D848F424 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dus-ascii"> <META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR></HEAD> <BODY> <DIV><SPAN class=3D990191810-13112006><FONT face=3DArial size=3D2>DM f +or = is attached=20 (56287)</FONT></SPAN></DIV></BODY></HTML> ------_=_NextPart_002_01C7070D.D848F424-- ------_=_NextPart_001_01C7070D.D848F424 Content-Type: application/msword; name="test ().doc" Content-Transfer-Encoding: base64 Content-Description: test ().doc Content-Disposition: attachment; filename="test ().doc" ------_=_NextPart_001_01C7070D.D848F424--'; my $parser = MIME::Parser->new(); $parser->extract_nested_messages(0); $parser->output_dir($tmp_dir); $entity = $parser->parse_data($message_source); for(glob("$tmp_dir/*")) { # ..... } rmtree("$tmp_dir", 0); # -------------------------------------------------------------------- +--------------------

THE PROBLEM IS WHEN STORE ATTACHMENT WITH "TEST ().DOC" NAME THE CREATED FILE HAS NAME: TEST %28%29.DOC

CAN SOMEONE HELP ME?

THANKS IN ADVANCE.

Edited (davorg): fixed formatting


In reply to Problem with MIME::Parser by dlegia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.