]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwattach: only pass the charset through if ASCII
authorEric Wong <e@80x24.org>
Tue, 4 Jun 2019 02:04:27 +0000 (02:04 +0000)
committerEric Wong <e@80x24.org>
Tue, 4 Jun 2019 10:06:18 +0000 (10:06 +0000)
AFAIK all names of charsets are ASCII, so passing non-ASCII
characters from emails to clients would probably confuse clients.

lib/PublicInbox/WwwAttach.pm

index d690ce411921b5fa40820b98923b53d23c1f001a..96103cb028e09b014e4bf29fb7e711c4e567ec08 100644 (file)
@@ -27,7 +27,7 @@ sub get_attach ($$$) {
                if ($ct && (($ct->{discrete} || '') eq 'text')) {
                        # display all text as text/plain:
                        my $cset = $ct->{attributes}->{charset};
-                       if ($cset && ($cset =~ /\A[\w-]+\z/)) {
+                       if ($cset && ($cset =~ /\A[a-zA-Z0-9_\-]+\z/)) {
                                $res->[1]->[1] .= qq(; charset=$cset);
                        }
                } else { # TODO: allow user to configure safe types