[issue25553] SMTP.data(msg) function may cause the last CRLF of msg lost if msg is quoted-printable encoding.

2015-11-04 Thread Deli Zhang

New submission from Deli Zhang:

It's well known that in quoted-printable encoding the "CRLF" can be encoded to 
"=CRLF".
For example, in attachment file test.eml, the last line is "test message.=CRLF"
But after the mail is sent via SMTP and received by mail server (e.g. postfix), 
the last line will become "test message.=", 
then after decoding, you will see the unnecessary char "=" shown following 
"test message.".

The problem is caused by below code:

class SMTP:
...
def data(self, msg):
...
q = quotedata(msg)
if q[-2:] != CRLF:
q = q + CRLF
q = q + "." + CRLF
self.send(q)
...

Before it sends the message q, it will try to append the end-of-data sequence 
".". 
As the implement, it checks whether there is "" in the message end, if 
yes then just need to append ".".
It looks rigorous and efficient, but it does not consider how mail server 
handle it.
As we know mail server will remove end-of-data sequence directly, and the left 
message is treat as mail data.

Thus the corresponding action should be taken on SMTP client side,
it's to say no need to check and just append end-of-data sequence here:

class SMTP:
...
def data(self, msg):
...
q = quotedata(msg)
q = q + CRLF + "." + CRLF
self.send(q)
...
----

--
components: Library (Lib)
files: test.eml
messages: 254086
nosy: Deli Zhang
priority: normal
severity: normal
status: open
title: SMTP.data(msg) function may cause the last CRLF of msg lost if msg is 
quoted-printable encoding.
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file40944/test.eml

___
Python tracker 
<http://bugs.python.org/issue25553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25553] SMTP.data(msg) function may cause the last CRLF of msg lost if msg is quoted-printable encoding.

2015-11-04 Thread Deli Zhang

Deli Zhang added the comment:

Correct the action of appending the end-of-data sequence "."

--
Added file: http://bugs.python.org/file40945/smtplib.py

___
Python tracker 
<http://bugs.python.org/issue25553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25553] SMTP.data(msg) function may cause the last CRLF of msg lost if msg is quoted-printable encoding.

2015-11-06 Thread Deli Zhang

Deli Zhang added the comment:

I can understand you, while could you please consider below fact:
Once our SMTP server module smtpd.py receives the sample mail, it will remove 
the end-of-data sequence, that makes the "=" become the last char of mail data. 
I think it's inconsistent to our SMTP client module smtplib.py.

If we can just add "." following mail data like postfix, which is 
influential amd authoritative in SMTP field, that will make things simple and 
will not make any trouble in reality situation.

I just advise this, if you think no need then I can compromise.
Thanks.

--

___
Python tracker 
<http://bugs.python.org/issue25553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com