[SOLVED] Header remove some parts

Raito00

Active Member
Sep 10, 2019
28
2
43
44
Hello!
I have problem with long file attachments if there is some special characters.
This problem is only affected roundcube clients and there is no fix right now.

So i need some temporary workaround to fix this issue.

Header part:

Code:
Content-Type: text/plain;
    name*0="=?UTF-8?B?Tm9ybWFsLUZpbGVfbmFtZS3EgcSTxLfEjcWrxJI=?=
 =?UTF-8"; name*1="?B?xaDEt8WGX0xvbmdlcl9maWxlbmFtZS50eHQ=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename.txt

I need remove from header all line if there is: name*0 or name*1

With webUI Mail Filter looks like there is no option to remove.
 
I need remove from header all line if there is: name*0 or name*1
I would strongly recommend to not remove the Content-type header of a mail-part - many clients, and software that handles mail, decides what to do with a mail based on this header.

With webUI Mail Filter looks like there is no option to remove.
PMG does not have functionality for arbitrary header-editing (and we currently do not plan on adding that) - you can try to achieve this by modifying the postfix configuration - but I'd suggest to - open an issue with roundcube, if the problem is in the mailclient there, ask the sender of those e-mails to no add these (at least to me not too-common looking) tags for the content-type header
 
Yes, it's not ideal to remove the Content-Type header, but in my case, I need to do something because, at the moment, there is no fix available from Roundcube.

So here is my temporary workaround:

/etc/postfix/header_checks
Code:
/^Content-Type: (.*?);[^;]*\bname\*0=.*$/ REPLACE Content-Type: $1;

/etc/pmg/templates/main.cf.in

add
Code:
# Add header_checks
header_checks = regexp:/etc/postfix/header_checks

Header before:
Code:
------=_Part_135587_2101741540.1734014174115--

------=_Part_135588_1896157637.1734014174115
Content-Type: text/plain;
    name="=?UTF-8?B?Tm9ybWFsX25hbWUtxIHEk8S3xI3Fq8SSxaDEt8WGLnR4dA==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86.txt

ZmlsZSBuYW1lIGhhdmUgYSBzcGVjaWFsIGNoYXIgYnV0IHNob3dpbmcgT0s=

------=_Part_135588_1896157637.1734014174115
Content-Type: text/plain;
    name*0="=?UTF-8?B?Tm9ybWFsLUZpbGVfbmFtZS3EgcSTxLfEjcWrxJI=?=
 =?UTF-8"; name*1="?B?xaDEt8WGX0xvbmdlcl9maWxlbmFtZS50eHQ=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename.txt

bG9uZ2VyIGZpbGUgbmFtZSBoYXZlIGEgc3BlY2lhbCBjaGFy

------=_Part_135588_1896157637.1734014174115
Content-Type: text/plain;
    name*0="=?UTF-8?B?Tm9ybWFsLUZpbGVfbmFtZS3EgcSTxLfEjcWrxJLFoMS3xYZfTG";
    name*1="9uZ2U=?=
 =?UTF-8?B?cl9maWxlbmFtZV9kb3VibGUtbG9uZyAtIENvcHkud";
    name*2="Hh0?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename_double-long%20-%20Copy.txt

bG9uZ2VyIGZpbGUgbmFtZSBoYXZlIGEgc3BlY2lhbCBjaGFy

------=_Part_135588_1896157637.1734014174115
Content-Type: text/plain;
    name*0="=?UTF-8?B?Tm9ybWFsLUZpbGVfbmFtZS3EgcSTxLfEjQ==?=
 =?UTF-8?B?x";
    name*1="avEksWgxLfFhl9Mb25nZXJfZmlsZW5hbWU=?=
 =?UTF-8?B?X2RvdWJsZS1s";
    name*2="b25ndsSTbCBnYXLEgWs=?=
 =?UTF-8?B?cy1kYXVkemdhcsSBa3NrxIEgY2l";
    name*3="0aWVt?=
 =?UTF-8?B?LXVuIHRhc2Ygc2Ygc2RmZGYgLXNmZC1mZGZkIGRmZC";
    name*4="BmLWRmIGRmZCBmLQ==?=
 =?UTF-8?B?ZGZnIGFzZGdmIC1hc2RmZyBhLXNkZ";
    name*5="yAtc2RnIGEtZGdmIC1hZyAtLnR4dA==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename_double-longv%C4%93l%20gar%C4%81ks-daudzgar%C4%81ksk%C4%81%20citiem-un%20tasf%20sf%20sdfdf%20-sfd-fdfd%20dfd%20f-df%20dfd%20f-dfg%20asdgf%20-asdfg%20a-sdg%20-sdg%20a-dgf%20-ag%20-.txt

1734016091772.png

Header after:

Code:
------=_Part_136275_1427688090.1734014829735--

------=_Part_136276_1452720390.1734014829735
Content-Type: text/plain;
    name="=?UTF-8?B?Tm9ybWFsX25hbWUtxIHEk8S3xI3Fq8SSxaDEt8WGLnR4dA==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86.txt

ZmlsZSBuYW1lIGhhdmUgYSBzcGVjaWFsIGNoYXIgYnV0IHNob3dpbmcgT0s=

------=_Part_136276_1452720390.1734014829735
Content-Type: text/plain;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename.txt

bG9uZ2VyIGZpbGUgbmFtZSBoYXZlIGEgc3BlY2lhbCBjaGFy

------=_Part_136276_1452720390.1734014829735
Content-Type: text/plain;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename_double-long%20-%20Copy.txt

bG9uZ2VyIGZpbGUgbmFtZSBoYXZlIGEgc3BlY2lhbCBjaGFy

------=_Part_136276_1452720390.1734014829735
Content-Type: text/plain;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename*=UTF-8''Normal-File_name-%C4%81%C4%93%C4%B7%C4%8D%C5%AB%C4%92%C5%A0%C4%B7%C5%86_Longer_filename_double-longv%C4%93l%20gar%C4%81ks-daudzgar%C4%81ksk%C4%81%20citiem-un%20tasf%20sf%20sdfdf%20-sfd-fdfd%20dfd%20f-df%20dfd%20f-dfg%20asdgf%20-asdfg%20a-sdg%20-sdg%20a-dgf%20-ag%20-.txt

1734016151714.png
 

Attachments

  • 1734016071982.png
    1734016071982.png
    26.5 KB · Views: 0
  • 1734016145004.png
    1734016145004.png
    18.1 KB · Views: 0