Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Does Email::MIME support attachments of files with utf8 filename?

My code crashed, and I think that may be the problem. Can anyone verify it?

EDIT:

I have a text file which is MIME-formatted (this is actually an email I got, and saved as a file. Never mind). The file itself is long, but I think the relevant part is:

--00000000000076fecc057dd5edea-- --00000000000076fece057dd5edec Content-Type: application/pdf; name="=?UTF-8?B?157Xmdec15kg15PXkNeR15X +Xqi5wZGY=?=" Content-Disposition: attachment; filename="=?UTF-8?B?157Xmdec15kg15PXk +NeR15XXqi5wZGY=?=" Content-Transfer-Encoding: base64 Content-ID: <167836db7a888894ca51> X-Attachment-Id: 167836db7a888894ca51

As you see, there's an attachment in the message, which happens to be a pdf file with non-ascii name. Now, my code is:

#!perl use Email::MIME; $file = shift || "g"; open G, $file; $g = join '', <G>; close G; $e = new Email::MIME ($g);

The code generated the following message:

Unquoted '"' not allowed at ./chfn.pl line 6.
Missing semicolon before parameter '"מילי דאבות.pdf"' at ./chfn.pl line 6.

The error is not fatal, that is, the code continues to run after generating this message. However I cannot extract the filename of the attachment using Email::MIME methods. Now, Consider this:

perl -pe 's/name=".*"/name="fn.pdf"/g' g >g2 ./chfn.pl g2

The result is no errors. I conclude that the problem is the non-ascii filename of the attachment. BTW ths OS is Linux, not Windows.

Thanks a lot!


In reply to Email::MIME support for utf8 filename by Arik123

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found