Hi,
I have to filter out some tags from outgoing email subject field. I use the following filter:
if $h_subject: matches \N\[\NTAG1|TAG2|TAG3\N\]\N
then
headers add "tmpSubject: ${sg{$bh_subject:}{\\\\[(TAG1|TAG2|TAG3)\\\\]\\\\ }{}}"
headers remove "Subject"
headers add "Subject: $h_tmpSubject"
headers remove "tmpSubject"
endif
and it works fine while users send emails with email clients and subject is ISO-8859-1 plain text. But some users do it with Google Mail’s web interface. Then outgoing email subject is in UTF-8 and encoded with Base64. Based on «String expansion» section of documentation, I have tried to add second stage to the filter with the same content, but prepended with
headers charset "UTF-8"
- no luck.
Then I’ve tried to determine the problem. I’ll bypass some intermediate steps, but I have ended with following in filter:
headers charset "UTF-8"
headers add "tmpB64decodedSubject: $bh_subject"
headers add "hSubject: $h_subject"
In my understanding of «String expansion» this both should result with additional headers, decoded from Base64 — however, I’m getting three identical headers:
Subject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
tmpB64decodedSubject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
hSubject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
Once again, according to my understanding of «String expansion» this means that Exim cannot decode the original header for some reason. I have tried to decode « UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4» manually on the same server with
echo UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4 | base64 -d
and it works fine:
Re: [EXTERNAL] Re: Re: Re: ????????????
(tag [EXTERNAL] is one of the actual tags in use).
What am I doing wrong in filters? Or how can I do further diagnostic to determine why Exim cannot decode the headers? Does multiline in subject header influences the result?
Best regards,
Kirill Sluchanko
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
I have to filter out some tags from outgoing email subject field. I use the following filter:
if $h_subject: matches \N\[\NTAG1|TAG2|TAG3\N\]\N
then
headers add "tmpSubject: ${sg{$bh_subject:}{\\\\[(TAG1|TAG2|TAG3)\\\\]\\\\ }{}}"
headers remove "Subject"
headers add "Subject: $h_tmpSubject"
headers remove "tmpSubject"
endif
and it works fine while users send emails with email clients and subject is ISO-8859-1 plain text. But some users do it with Google Mail’s web interface. Then outgoing email subject is in UTF-8 and encoded with Base64. Based on «String expansion» section of documentation, I have tried to add second stage to the filter with the same content, but prepended with
headers charset "UTF-8"
- no luck.
Then I’ve tried to determine the problem. I’ll bypass some intermediate steps, but I have ended with following in filter:
headers charset "UTF-8"
headers add "tmpB64decodedSubject: $bh_subject"
headers add "hSubject: $h_subject"
In my understanding of «String expansion» this both should result with additional headers, decoded from Base64 — however, I’m getting three identical headers:
Subject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
tmpB64decodedSubject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
hSubject: =?UTF-8?B?UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4?= Ñ Ð¿Ð¾Ñ?Ñ?Ñ?
Once again, according to my understanding of «String expansion» this means that Exim cannot decode the original header for some reason. I have tried to decode « UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4» manually on the same server with
echo UmU6IFtFWFRFUk5BTF0gUmU6IFJlOiBSZTog0JzQsNGA0YjRgNGD0YLQuNC30LDRhtC4 | base64 -d
and it works fine:
Re: [EXTERNAL] Re: Re: Re: ????????????
(tag [EXTERNAL] is one of the actual tags in use).
What am I doing wrong in filters? Or how can I do further diagnostic to determine why Exim cannot decode the headers? Does multiline in subject header influences the result?
Best regards,
Kirill Sluchanko
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/