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

Broken content type parsing of encoded parameters #61

Open
dlucredativ opened this issue Oct 25, 2019 · 9 comments
Open

Broken content type parsing of encoded parameters #61

dlucredativ opened this issue Oct 25, 2019 · 9 comments

Comments

@dlucredativ
Copy link
Contributor

root@1f1df024bf37:~# perl -MEmail::MIME -e 'Email::MIME->new(join "", <>)' <<EOD
Content-Type: application/gzip;
 name="=?UTF-8?Q?b=c3=a4r.gz?="
EOD
Unquoted '"' not allowed at -e line 1.
Missing semicolon before parameter '"b�r.gz"' at -e line 1.
root@1f1df024bf37:~# patch -p1 /usr/share/perl5/Email/MIME.pm < content_type.patch
patching file /usr/share/perl5/Email/MIME.pm
root@1f1df024bf37:~# perl -MEmail::MIME -e 'Email::MIME->new(join "", <>)' <<EOD
Content-Type: application/gzip;
 name="=?UTF-8?Q?b=c3=a4r.gz?="
EOD
root@1f1df024bf37:~# cat content_type.patch 
--- /usr/share/perl5/Email/MIME.pm	2019-10-25 13:17:37.734030211 +0000
+++ /usr/share/perl5/Email/MIME.pm.patched	2019-10-25 13:12:08.753521633 +0000
@@ -134,7 +134,7 @@
 
   my $self = shift->SUPER::new($text, $arg, @rest);
   $self->encode_check_set($encode_check);
-  $self->{ct} = parse_content_type($self->content_type);
+  $self->{ct} = parse_content_type($self->content_type_raw);
   $self->parts;
   return $self;
 }
@@ -422,6 +422,7 @@
 sub force_decode_hook { 0 }
 sub decode_hook       { return $_[1] }
 sub content_type      { scalar shift->header("Content-type"); }
+sub content_type_raw  { scalar shift->header_raw("Content-type"); }
 
 sub debug_structure {
   my ($self, $level) = @_;
root@1f1df024bf37:~# 
@dxdc
Copy link
Contributor

dxdc commented Oct 25, 2019

@pali created several PR's a while ago, which have never been implemented. They work from my testing to address these kinds of issues.

#51

@pali
Copy link
Contributor

pali commented Oct 25, 2019

For more then 2 years there is implemented support for Unicode parameters in content type and content disposition headers in my pull request: #51
But maintainer is ignoring me and also these bug reports... So Email:: looks like already as abandonware...

@pali
Copy link
Contributor

pali commented Oct 25, 2019

So.. I do not have motivation to look at Email:: modules...

@gtech99
Copy link

gtech99 commented Dec 8, 2023

From what I see now, all these PRs have been merged and are present in the latest version of Email::MIME

however, they don't solve the error mentioned in this issue.

Can you guys see if you still get this error ?

@dlucredativ
Copy link
Contributor Author

however, they don't solve the error mentioned in this issue.

Seems to work for me:

root@4cb9f812c9f2:~# apt policy libemail-mime-perl
libemail-mime-perl:
  Installed: 1.953-1
  Candidate: 1.953-1
  Version table:
 *** 1.953-1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status
root@4cb9f812c9f2:~# perl -MEmail::MIME -e 'Email::MIME->new(join "", <>)' <<EOD
Content-Type: application/gzip;
 name="=?UTF-8?Q?b=c3=a4r.gz?="
EOD
root@4cb9f812c9f2:~# 

@gtech99
Copy link

gtech99 commented Dec 8, 2023

Ah, you have encoded file names. But straight UTF-8 file names still break.
for example:

t1.txt contains: Content-Type: application/pdf; name="ConvocaçãoPCO.pdf"

perl -MEmail::MIME -e 'Email::MIME->new(join "", <>)' < t1.txt
Unquoted '"' not allowed at -e line 1.
Missing semicolon before parameter '"ConvocaçãoPCO.pdf"' at -e line 1.

Can you test as well please ?

@dlucredativ
Copy link
Contributor Author

Ah, you have encoded file names. But straight UTF-8 file names still break. for example:

t1.txt contains: Content-Type: application/pdf; name="ConvocaçãoPCO.pdf"

RFC 6532 support deserves an own issue / feature request in my opinion. There is more to check than Email::MIME::ContentType.

@gtech99
Copy link

gtech99 commented Dec 9, 2023

ok, so in other words, you confirm the issue ?

@dlucredativ
Copy link
Contributor Author

ok, so in other words, you confirm the issue ?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants