Re: [exim] raw mime_filename

2022-10-20 Thread Jasen Betts via Exim-users
On 2022-10-13, Mikhail Golub via Exim-users  wrote:
> Hi.
>
> How can I get "raw" $mime_filename ?
>
> In Exim - "headers_charset = UTF-8".
> And if file name of attachment not in utf8 i have a problem with log 
> display.
> Example from log, $mime_filename:
> "▒▒ ▒▒▒ 12_10_22.xlsx"
>
> I could use ... embedded Perl (use Encode).
> If i got raw mime_filename ...
>
> Or can you recommend an easier way get filename in log in utf8 encoding?

nothing that can be relied upon.

last week I saw an attachment with lots of high-bit bytes in the
filename, not UTF-8, and no explicit announcement of the character set.

deny
  condition = $if(eq{$mime_filename}{${utf8clean:$mime_filename}{no}{yes}}
  message=unnaceptable attachment filename please follow RFC

-- 
  Jasen.

-- 
## 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/


Re: [exim] raw mime_filename

2022-10-18 Thread Mikhail Golub via Exim-users

Exim version 4.95 #5 (FreeBSD 12.3) built 18-Oct-2022 13:42:33
Copyright (c) University of Cambridge, 1995 - 2018
(c) The Exim Maintainers and contributors in ACKNOWLEDGMENTS file, 2007 
- 2020

Probably Berkeley DB version 1.8x (native mode)
Support for: crypteq iconv() use_setclassresources Expand_dlfunc OpenSSL 
TLS_resume Content_Scanning DKIM DMARC PIPE_CONNECT 
Experimental_Queue_Ramp SPF SRS TCP_Fast_Open Experimental_ARC
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm 
dbmjz dbmnz dnsdb dsearch ldap ldapdn ldapm mysql passwd

Authenticators: plaintext
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/mbx autoreply pipe smtp


In exim config:
warn condition = ${if def:mime_filename}
logwrite = TEST: $mime_filename


With this mime part (utf-8) all ok:

--hJ1w4fdd7nJgV1TgS95Plkir
Content-Type: text/plain; charset=UTF-8;
 name="=?UTF-8?B?0L/QtdGA0LXQstGW0YDQutCw0ZfSkS50eHQ=?="
Content-Disposition: attachment;
 filename*0*=UTF-8''%D0%BF%D0%B5%D1%80%D0%B5%D0%B2%D1%96%D1%80%D0%BA%D0%B0;
 filename*1*=%D1%97%D2%91%2E%74%78%74
Content-Transfer-Encoding: base64

ZGdkZmdkZg==

--hJ1w4fdd7nJgV1TgS95Plkir--


Exim running with debug:
pBj0VVcSTH1a84AUmONrMFYf
13:45:06 71378 MIME: found content-type: header, value is 'text/plain'
13:45:06 71378 MIME:   considering paramlist 
'charset=UTF-8;name="=?UTF-8?B?0L/QtdGA0LXQstGW0YDQutCw0ZfSkS50eHQ=?=";'
13:45:06 71378 MIME:  found charset= parameter in content-type: header, 
value 'UTF-8'
13:45:06 71378 MIME:   considering paramlist 
'name="=?UTF-8?B?0L/QtdGA0LXQstGW0YDQutCw0ZfSkS50eHQ=?=";'
13:45:06 71378 MIME:  found name= parameter in content-type: header, 
value 'перевіркаїґ.txt'
13:45:06 71378 MIME: found content-disposition: header, value is 
'attachment'
13:45:06 71378 MIME:   considering paramlist 
'filename*0*=UTF-8''%D0%BF%D0%B5%D1%80%D0%B5%D0%B2%D1%96%D1%80%D0%BA%D0%B0;filename*1*=%D1%97%D2%91%2E%74%78%74;'
13:45:06 71378 MIME:   considering paramlist 
'filename*1*=%D1%97%D2%91%2E%74%78%74;'
13:45:06 71378 MIME:  found filename parameter in content-disposition: 
header, value is 'перевіркаїґ.txt'
13:45:06 71378 MIME: found content-transfer-encoding: header, value is 
'base64'

13:45:06 71378 using ACL "acl_check_mime"
13:45:06 71378 processing "warn" (/usr/local/etc/exim/configure 358)
13:45:06 71378 check decode = default
13:45:06 71378 warn: condition test succeeded in ACL "acl_check_mime"
13:45:06 71378 processing "warn" (/usr/local/etc/exim/configure 362)
13:45:06 71378  ╭considering: ${if def:mime_filename}
13:45:06 71378  ├──condition: def:mime_filename
13:45:06 71378  ├─result: true
13:45:06 71378  ├──expanding: ${if def:mime_filename}
13:45:06 71378  ╰─result: true
13:45:06 71378 check condition = ${if def:mime_filename}
13:45:06 71378 = true
13:45:06 71378  ╭considering: TEST: $mime_filename
13:45:06 71378  ├──expanding: TEST: $mime_filename
13:45:06 71378  ╰─result: TEST: перевіркаїґ.txt
13:45:06 71378 ╰──(tainted)
13:45:06 71378 check logwrite = TEST: $mime_filename
13:45:06 71378= TEST: перевіркаїґ.txt
13:45:06 71378 LOG: MAIN
13:45:06 71378   TEST: перевіркаїґ.txt



Have a problem with this MIME part (windows-1251):
0D414212928A8F055
Content-Type: text/plain; charset=windows-1251
Content-Transfer-Encoding: quoted-printable

=EF=E5=F0=E5=E2=B3=F0=EA=E0
0D414212928A8F055
Content-Type: TEXT/PLAIN;
 name="=?windows-1251?Q?=EF=E5=F0=E5=E2=B3=F0=EA=E0=BF=B4=2Etxt?="
Content-transfer-encoding: base64
Content-Disposition: attachment;
 filename="=?windows-1251?Q?=EF=E5=F0=E5=E2=B3=F0=EA=E0=BF=B4=2Etxt?="

ZGdkZmdkZg==
0D414212928A8F055--

Debug:
17:34:38 71940 MIME: Next part with boundary --0D414212928A8F055
17:34:38 71940 MIME: found content-type: header, value is 'text/plain'
17:34:38 71940 MIME:   considering paramlist 
'name="=?windows-1251?Q?=EF=E5=F0=E5=E2=B3=F0=EA=E0=BF=B4=2Etxt?=";'
17:34:38 71940 MIME:  found name= parameter in content-type: header, 
value '▒▒▒࿴.txt'
17:34:38 71940 MIME: found content-transfer-encoding: header, value is 
'base64'
17:34:38 71940 MIME: found content-disposition: header, value is 
'attachment'
17:34:38 71940 MIME:   considering paramlist 
'filename="=?windows-1251?Q?=EF=E5=F0=E5=E2=B3=F0=EA=E0=BF=B4=2Etxt?=";'
17:34:38 71940 MIME:  found filename= parameter in content-disposition: 
header, value '▒▒▒࿴.txt'
17:34:38 71940 MIME:  found filename parameter in content-disposition: 
header, value is '▒▒▒࿴.txt'

17:34:38 71940 using ACL "acl_check_mime"
17:34:38 71940 processing "warn" (/usr/local/etc/exim/configure 362)
17:34:38 71940  ╭considering: ${if def:mime_filename}
17:34:38 71940  ├──condition: def:mime_filename
17:34:38 71940  ├─result: true
17:34:38 71940  ├──expanding: ${if def:mime_filename}
17:34:38 71940  ╰─result: true
17:34:38 71940 check condition = ${if def:mime_filename}

Re: [exim] raw mime_filename

2022-10-18 Thread Mikhail Golub via Exim-users

Developers, can you help me?

On 14.10.2022 18:03, Andrew C Aitchison wrote:

On Fri, 14 Oct 2022, Mikhail Golub via Exim-users wrote:


One more example.

In letter:
Content-Description: =?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=

In $mime_content_description:
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=

Compare it:
=?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=


I have a script https://www.aitchison.me.uk/clearsubject.pl
piping the above though it gives:
--
In letter:
Content-Description: Вход_Выход.xlsx

In $mime_content_description:
ВьnеяЬыьnеОxnш

Compare it:
Вход_Выход.xlsx
ВьnеяЬыьnеОxnш
--

So $mime_content_description: has not preserved the case of the encoded 
text,

which means that the decoded version is wrong !




--
## 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/


Re: [exim] raw mime_filename

2022-10-14 Thread Andrew C Aitchison via Exim-users

On Fri, 14 Oct 2022, Mikhail Golub via Exim-users wrote:


One more example.

In letter:
Content-Description: =?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=

In $mime_content_description:
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=

Compare it:
=?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=


I have a script https://www.aitchison.me.uk/clearsubject.pl
piping the above though it gives:
--
In letter:
Content-Description: Вход_Выход.xlsx

In $mime_content_description:
ВьnеяЬыьnеОxnш

Compare it:
Вход_Выход.xlsx
ВьnеяЬыьnеОxnш
--

So $mime_content_description: has not preserved the case of the encoded text,
which means that the decoded version is wrong !

However, Jeremy said you should be looking at $mime_content_disposition
- does this preserved case ?
Note: the variable should contain the text of the continuation lines, nut 
just the first line of this header.



On 14.10.2022 12:47, Mikhail Golub via Exim-users wrote:

ok.

Given in letter:
Content-Description: Elinta Charge CityCharge WiFi configuration.pdf

I got this in $mime_content_description:
elintachargecitychargewificonfiguration.pdf



On 14.10.2022 12:38, Jeremy Harris via Exim-users wrote:

On 14/10/2022 10:18, Mikhail Golub via Exim-users wrote:

What is meant by "normalized content"?


Interpreting the sourcecode, it looks like:
stuff up to the first ; is dropped, then a 2047-decode is done.






--
## 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/



--
Andrew C. Aitchison  Kendal, UK
   and...@aitchison.me.uk
--
## 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/


Re: [exim] raw mime_filename

2022-10-14 Thread Mikhail Golub via Exim-users

One more example.

In letter:
Content-Description: =?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=

In $mime_content_description:
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=

Compare it:
=?windows-1251?B?wvXu5F/C+/Xu5C54bHN4?=
=?windows-1251?b?wvxu5f/c+/xu5c54bhn4?=



On 14.10.2022 12:47, Mikhail Golub via Exim-users wrote:

ok.

Given in letter:
Content-Description: Elinta Charge CityCharge WiFi configuration.pdf

I got this in $mime_content_description:
elintachargecitychargewificonfiguration.pdf



On 14.10.2022 12:38, Jeremy Harris via Exim-users wrote:

On 14/10/2022 10:18, Mikhail Golub via Exim-users wrote:

What is meant by "normalized content"?


Interpreting the sourcecode, it looks like:
stuff up to the first ; is dropped, then a 2047-decode is done.






--
## 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/


Re: [exim] raw mime_filename

2022-10-14 Thread Mikhail Golub via Exim-users

ok.

Given in letter:
Content-Description: Elinta Charge CityCharge WiFi configuration.pdf

I got this in $mime_content_description:
elintachargecitychargewificonfiguration.pdf



On 14.10.2022 12:38, Jeremy Harris via Exim-users wrote:

On 14/10/2022 10:18, Mikhail Golub via Exim-users wrote:

What is meant by "normalized content"?


Interpreting the sourcecode, it looks like:
stuff up to the first ; is dropped, then a 2047-decode is done.



--
## 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/


Re: [exim] raw mime_filename

2022-10-14 Thread Jeremy Harris via Exim-users

On 14/10/2022 10:18, Mikhail Golub via Exim-users wrote:

What is meant by "normalized content"?


Interpreting the sourcecode, it looks like:
stuff up to the first ; is dropped, then a 2047-decode is done.
--
Cheers,
  Jeremy


--
## 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/


Re: [exim] raw mime_filename

2022-10-14 Thread Mikhail Golub via Exim-users


I have email message:
Content-Description: Elinta Charge CityCharge WiFi configuration.pdf
Content-Disposition: attachment;
filename="Elinta Charge CityCharge WiFi configuration.pdf"; size=548769;

In exim config (acl_smtp_mime):
logwrite = TEST: mime_filename="$mime_filename"\
${if and { \
{def:mime_content_description} \
{!match{$mime_content_description}{(?i)^=\?utf-8}} \
{match{$mime_content_description}{^=\?}} \
} \
{, mime_content_description="$mime_content_description", \
${rfc2047d:$mime_content_description}}}



I got this:
TEST: mime_filename="Elinta Charge CityCharge WiFi configuration.pdf", 
mime_content_description="elintachargecitychargewificonfiguration.pdf", 
elintachargecitychargewificonfiguration.pdf


Why mime_content_description not does not match header 
"Content-Description" in letter?


In documentation:
"$mime_content_description
This variable contains the normalized content of the 
Content-Description: header. It can contain a human-readable description 
of the parts content. Some implementations repeat the filename for 
attachments here, but they are usually only used for display purposes."


What is meant by "normalized content"?


On 13.10.2022 22:55, Jeremy Harris via Exim-users wrote:

On 13/10/2022 20:41, Mikhail Golub via Exim-users wrote:

Content-Disposition: attachment;
 filename="=?windows-1251?B?wevg7eog7/Du7+7n6Pazvy5kb2N4?="; size=48777;


Here:   ^


 creation-date="Wed, 25 Aug 2021 08:33:00 GMT";
 modification-date="Thu, 13 Oct 2022 07:06:59 GMT"





--
## 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/


Re: [exim] raw mime_filename

2022-10-13 Thread Jeremy Harris via Exim-users

On 13/10/2022 20:41, Mikhail Golub via Exim-users wrote:

Content-Disposition: attachment;
 filename="=?windows-1251?B?wevg7eog7/Du7+7n6Pazvy5kb2N4?="; size=48777;


Here:   ^


 creation-date="Wed, 25 Aug 2021 08:33:00 GMT";
 modification-date="Thu, 13 Oct 2022 07:06:59 GMT"


--
Cheers,
  Jeremy


--
## 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/


Re: [exim] raw mime_filename

2022-10-13 Thread Mikhail Golub via Exim-users

Thanks for reply.

mime_content_disposition - it's not that :(
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-content_scanning_at_acl_time.html

$mime_content_disposition

This variable contains the normalized content of the 
Content-Disposition: header. You can expect strings like “attachment” or 
“inline” here.



Headers example:
Content-Disposition: attachment;
filename="=?windows-1251?B?wevg7eog7/Du7+7n6Pazvy5kb2N4?="; size=48777;
creation-date="Wed, 25 Aug 2021 08:33:00 GMT";
modification-date="Thu, 13 Oct 2022 07:06:59 GMT"
Content-Transfer-Encoding: base64


If I get "raw" $mime_filename, i can do convert in perl:
use Encode;
$utf8 = decode('MIME-Header', $unknown_variable_raw_mime_filename);

Maybe $mime_content_description?
But not always present :(

mime_filename=помилкаАрт1665572404626.docx, mime_content_description=
mime_filename=Скрин11665574157026.jpg, mime_content_description=
mime_filename=▒.txt, mime_content_description=


On 13.10.2022 20:34, Jeremy Harris via Exim-users wrote:

On 13/10/2022 17:57, Mikhail Golub via Exim-users wrote:

How can I get "raw" $mime_filename ?

In Exim - "headers_charset = UTF-8".
And if file name of attachment not in utf8 i have a problem with log 
display.

Example from log, $mime_filename:
"▒▒ ▒▒▒ 12_10_22.xlsx"


Have a look at $mime_content_disposition - this is where the $mime_filename
was extracted from.  If I read the code right, the encoded value there 
could

include a filename-charset as well as the file name.

Relevant standards seem to be RFC 2231, RFC 2047.




--
## 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/


Re: [exim] raw mime_filename

2022-10-13 Thread Jeremy Harris via Exim-users

On 13/10/2022 17:57, Mikhail Golub via Exim-users wrote:

How can I get "raw" $mime_filename ?

In Exim - "headers_charset = UTF-8".
And if file name of attachment not in utf8 i have a problem with log display.
Example from log, $mime_filename:
"▒▒ ▒▒▒ 12_10_22.xlsx"


Have a look at $mime_content_disposition - this is where the $mime_filename
was extracted from.  If I read the code right, the encoded value there could
include a filename-charset as well as the file name.

Relevant standards seem to be RFC 2231, RFC 2047.

--
Cheers,
  Jeremy


--
## 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/