Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters not handled properly in attachment names #233

Closed
shawniverson opened this issue Oct 4, 2018 · 15 comments · Fixed by #334
Closed

Unicode characters not handled properly in attachment names #233

shawniverson opened this issue Oct 4, 2018 · 15 comments · Fixed by #334

Comments

@shawniverson
Copy link
Member

mailwatch/MailWatch#1109

@shawniverson
Copy link
Member Author

Filename not being written to queue with this character and bypassing scan.

temp象.cer

@shawniverson
Copy link
Member Author

Traced back to Explode function in Message.pm...

@shawniverson
Copy link
Member Author

Appears to be an issue with the MIME Parser...

@shawniverson
Copy link
Member Author

Filename is encoded and doesn't appear to be parsed...

Content-Type: application/x-x509-ca-cert; name="=?UTF-8?B?dGVtcOixoS5jZXI=?="
Content-Disposition: attachment; filename="=?UTF-8?B?dGVtcOixoS5jZXI=?="

@shawniverson
Copy link
Member Author

Non unicode filename...

Content-Type: application/x-x509-ca-cert; name="temp.cer"
Content-Disposition: attachment; filename="temp.cer"

@shawniverson
Copy link
Member Author

Appears to be a bug in MIME::Parser, reported bug, trying MIME::Fast instead.

@shawniverson
Copy link
Member Author

Bump...MIME::Fast seems to be stale...

@shawniverson
Copy link
Member Author

Stop gap measure: set decode_headers to 1 for now until the bug in MIME::Parser is resolved. Only option at the moment unless someone has a better idea. At least it will attempt to decode the header and create a file.

@shawniverson
Copy link
Member Author

Leaving issue open until permanent fix is found.

@shawniverson
Copy link
Member Author

Revisiting, may be related to faulty handler in WordDecorder I just discovered...

@shawniverson
Copy link
Member Author

Looks related, but is triggered internally in MIME::Parser and cannot intercept. Will need to keep researching this.

@shawniverson
Copy link
Member Author

shawniverson commented Oct 27, 2018

Researching Email::MIME

@thctlo
Copy link
Contributor

thctlo commented Nov 7, 2018

Yesterday me and my collega where solving simular problem.
in the end we used in our perl script to send mails.
This is the script we used in the end.
We import a file and line 1 = to, 2= from, 3,= subject .. aah you know this, just have a look at the script.
it solve our ü in names and subject. mime conversions is no fun.

I hope you can use it, or give you ideas.

on Debian 9 its : apt install libmime-lite-tt-perl
source info : https://metacpan.org/pod/MIME::Lite::TT::HTML

#!/bin/perl
$mail_prog = "/usr/lib/sendmail";
use warnings;
use MIME::Lite::TT::HTML;

open (FILE,"/tmp/tmp-mail-To-Import") || die "Can't make /tmp/tmp-mail-To-Import\n";
@filecontent = <FILE>;
close(FILE);
$to = $filecontent[0];
$from = $filecontent[1];
$subject = $filecontent[2];
chomp($to);
chomp($from);
chomp($subject);
$filecontent[0] = "";
$filecontent[1] = "";
$filecontent[2] = "";
my $msg = MIME::Lite::TT::HTML->new(
                    From        =>  '$from',
                    To          =>  '$to',
                    Subject     =>  '$subject',
                    Template    =>   {'@filecontent'},
);
$msg->send;

exit;

@thctlo
Copy link
Contributor

thctlo commented Nov 7, 2018

the other option we use is :

use Encode qw(decode encode);
pen (FILE,"/tmp/tmp-mail-To-Import") || die "Can't make /tmp/tmp-mail-To-Import\n";
@filecontent = <FILE>;
close(FILE);
$to = $filecontent[0];
$from = $filecontent[1];
$subject = $filecontent[2];
chomp($to);
chomp($from);
chomp($subject);
$filecontent[0] = "";
$filecontent[1] = "";
$filecontent[2] = "";
my $subject_encoded = encode("MIME-Q", $subject);

this one is in my optinion the best, but im no coder..

shawniverson added a commit to shawniverson/v5 that referenced this issue Dec 9, 2018
shawniverson added a commit to shawniverson/v5 that referenced this issue Dec 9, 2018
shawniverson added a commit to shawniverson/v5 that referenced this issue Dec 9, 2018
@shawniverson
Copy link
Member Author

Problem appears to be no longer present after commit 481eed1 using MIME::Tools version 5.509 with decode_headers turned off.

Should have checked this again before all the hassle 😆

Preparing to disable workaround.

shawniverson added a commit to shawniverson/v5 that referenced this issue Dec 16, 2018
shawniverson added a commit that referenced this issue Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants