[issue28463] Email long headers parsing/serialization

2021-11-26 Thread Irit Katriel


Change by Irit Katriel :


--
type:  -> behavior
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-18 Thread R. David Murray

R. David Murray added the comment:

It is a bug, but it is not a bug that the message-id body gets put on a second 
line.  The old (compat32) folder introduces an extra space while folding, which 
then gets preserved when the re-parsing is done.  The new folder 
(policy=default) folds correctly (putting the id on a separate line), but the 
parser fails to remove the leading blank from the value when it is parsed.  It 
should remove the leading blank because that blank "belongs" to the header 
label (the "Message-Id:" part).  The RFC caution about whitespace only lines 
applies to whole lines; the first line in the present example is not blank 
because it has the header label on it.

I also need to add a test with a Message-Id that is in itself longer than 77 
characters.  Such a header can't be folded, so it will have to be emitted with 
a length longer than the default.  (And yes, the default can be changed to any 
value you like, see Policy.max_line_len).

--

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-18 Thread Константин Волков

Константин Волков added the comment:

But message ID have its own syntax https://www.ietf.org/rfc/rfc2822.txt:

3.6.4. Identification fields

message-id  =   "Message-ID:" msg-id CRLF
msg-id  =   [CFWS] "<" id-left "@" id-right ">" [CFWS]

3.2.3. Folding white space and comments

However, where CFWS occurs in this standard, it MUST NOT be inserted
   in such a way that any line of a folded header field is made up
   entirely of WSP characters and nothing else.

Its not obvious, but it seems that there must be no CRLF symbol before 
MessageID.

--

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-18 Thread Mariusz Masztalerczuk

Mariusz Masztalerczuk added the comment:

I think that it is not bug. It is just rfc ;) Due to 
https://www.ietf.org/rfc/rfc2822.txt, 

A message consists of header fields, optionally followed by a message
   body.  Lines in a message MUST be a maximum of 998 characters
   excluding the CRLF, but it is RECOMMENDED that lines be limited to 78
   characters excluding the CRLF

Because you have the line with the size more then 78 chars (the header + 
value), the python is trying to break this line into two. 

Maybe there should be option to increase this value to something more then 78? 
(because max is 998 due to rfc)

--
nosy: +mmasztalerczuk

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-17 Thread R. David Murray

R. David Murray added the comment:

Ah, interesting case.  Both the old folder/parser and the new folder/parser 
fail, in slightly different ways.  I'll have to add this test case to the tests 
as I finish rewriting the folder.  Thanks for the report.

--

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-17 Thread Константин Волков

Константин Волков added the comment:

Something with inserting long strings here. Its duplicating for some reason.
Adding example as attachment.

--
Added file: http://bugs.python.org/file45124/test.py

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-17 Thread Константин Волков

Константин Волков added the comment:

Something with copy paste.
x = '<147672320775.19544.6718708004153358...@mkren-spb.root.devdomain.local>'

--

___
Python tracker 

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



[issue28463] Email long headers parsing/serialization

2016-10-17 Thread Константин Волков

New submission from Константин Волков:

There is strange thing with long headers serialized, they have \n prefix. 
Example fails on Python3.4/3.5:

from email.message import Message
from email import message_from_bytes

x = '<147672320775.19544.6718708004153358...@mkren-spb.root.devdomain.local>'
header = 'Message-ID'
msg = Message()
msg[header] = x

data = msg.as_bytes()

msg2 = message_from_bytes(data)
print(x)
print(msg2[header])
assert msg2[header] == x


MessageID was generated by email.utils.make_msgid function.

--
components: email
messages: 278820
nosy: barry, r.david.murray, Константин Волков
priority: normal
severity: normal
status: open
title: Email long headers parsing/serialization
versions: Python 3.4, Python 3.5

___
Python tracker 

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