[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-21 Thread Ned Deily


Change by Ned Deily :


--
keywords: +security_issue
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.6, Python 3.9

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-21 Thread Ned Deily


Ned Deily  added the comment:


New changeset 79a47e2b9cff6c9facdbc022a752177ab89dc533 by Ned Deily (Miss 
Islington (bot)) in branch '3.6':
Fix infinite loop in email folding logic (GH-12732) (GH-14799)
https://github.com/python/cpython/commit/79a47e2b9cff6c9facdbc022a752177ab89dc533


--
nosy: +ned.deily

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread miss-islington


miss-islington  added the comment:


New changeset e7bec26937ce602ca21cc1f78a391adcf5eafdf1 by Miss Islington (bot) 
in branch '3.7':
Fix infinite loop in email folding logic (GH-12732)
https://github.com/python/cpython/commit/e7bec26937ce602ca21cc1f78a391adcf5eafdf1


--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread miss-islington


miss-islington  added the comment:


New changeset 6a2aec0ff587032beb8aac8cbebb09e7a52f6694 by Miss Islington (bot) 
in branch '3.8':
Fix infinite loop in email folding logic (GH-12732)
https://github.com/python/cpython/commit/6a2aec0ff587032beb8aac8cbebb09e7a52f6694


--
nosy: +miss-islington

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14595
pull_request: https://github.com/python/cpython/pull/14799

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:


New changeset f69d5c61981ea97d251db515c7ff280fcc17182d by Barry Warsaw (Paul 
Ganssle) in branch 'master':
Fix infinite loop in email folding logic (GH-12732)
https://github.com/python/cpython/commit/f69d5c61981ea97d251db515c7ff280fcc17182d


--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14594
pull_request: https://github.com/python/cpython/pull/14798

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-07-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +14593
pull_request: https://github.com/python/cpython/pull/14797

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread R. David Murray


R. David Murray  added the comment:

Right, one of the fundamental principles of the email library is that when 
parsing input we do not ever raise an error.  We may note defects, but whatever 
we get we *must* parse and turn in to *something*.

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread Abhilash Raj


Abhilash Raj  added the comment:

I was wrong about the parsing error, it looks like length from the policy isn't 
used when parsing.

>>> from email.policy import default
>>> from email import message_from_string
>>> p = default.clone(max_line_length=10)
>>> msg = message_from_string("""\
... From: he...@example.com
... To: he...@example.com
... Subject: WelcomeToThisLongSubject
... 
... Thanks""", policy=p)
>>> msg

>>> msg['Subject']
'WelcomeToThisLongSubject'


This works just fine. Thanks David. +1 for ValueError then.

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread R. David Murray


R. David Murray  added the comment:

Good point about the backward compatibility.  Yes I agree, I think raising the 
error is probably better.  A deprecation warning seems like a good path 
forward...I will be very surprised if anyone encounters it, though :)

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread Paul Ganssle


Paul Ganssle  added the comment:

Responding to a comment on the PR:

> Now, that said you might want to consider the fact that in 
> _fold_mime_parameters I deal with this issue by bumping maxlen to 78 rather 
> than raising an error. I'm not sure that was the right choice, but whatever 
> we do, it should probably be made consistent between the two cases.

So I think in an ideal world this would be consistent between the two, but I 
*also* think that the right solution is to raise an exception rather than 
silently coercing, and changing this in _fold_mime_parameters would be a 
backwards-incompatible change.

I think that if you agree that an exception is better, maybe the path forward 
is to raise an exception in this case and switch the _fold_mime_parameters case 
over to raising a warning, which will be turned into an exception in a later 
release (3.10 maybe).

> It is so sad that I never came back to fix that XXX comment I left myself :(

I'm glad that the XXX comment was at least there! Otherwise I wouldn't have 
notice that there was anything to fix!

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread R. David Murray


R. David Murray  added the comment:

As for the other, I don't see the need for a custom error.  It's a ValueError 
in my view.  I wouldn't object to it strongly, but note that this error is 
content dependent.  If there's nothing to encode, you can "get away with" a 
shorter maxlen.  Though why you would want to is beyond me, and that's another 
reason I don't think this warrants a custom error class.

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-17 Thread R. David Murray


R. David Murray  added the comment:

Can you demonstrate the parsing error?  maxlen should have no effect during 
parsing.

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-16 Thread Abhilash Raj


Abhilash Raj  added the comment:

Moving the conversation here from https://github.com/python/cpython/pull/12732 
for David.

I previously suggested HeaderParseError because of the fact that we could fail 
to parse a value into a Header Object in the above scenario.

@r.david.murray Would it be more appropriate to have something like a 
"PolicyError" in case where the policy's max_line_length isn't long enough to 
fit the shortest encoded word?

--

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-05-15 Thread Paul Ganssle


Change by Paul Ganssle :


--
nosy: +maxking, msapiro

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Paul Ganssle


Change by Paul Ganssle :


--
keywords: +patch
pull_requests: +12655
stage:  -> patch review

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Paul Ganssle


New submission from Paul Ganssle :

When reviewing PR 12020 fixing an infinite loop in the e-mail module, I noticed 
that a *different* infinite loop is documented with a "# XXX" comment on line 
2724:

https://github.com/python/cpython/blob/58721a903074d28151d008d8990c98fc31d1e798/Lib/email/_header_value_parser.py#L2724

This is triggered when the policy's `max_line_length` is set to be shorter than 
minimum line length required by the "RFC 2047 chrome". It can be reproduced 
with:

from email.policy import default

policy = default.clone(max_line_length=7) # max_line_length = 78
policy.fold("Subject", "12345678")

I could not find an entry on the tracker for this bug, but it is documented in 
the source code itself, so maybe I just didn't try hard enough.

Related but distinct bugs: #33529, #33524

I will submit a patch to fix this.

--
messages: 339660
nosy: barry, p-ganssle, r.david.murray
priority: normal
severity: normal
status: open
title: Infinite loop with short maximum line lengths in EmailPolicy
versions: Python 3.7, Python 3.8

___
Python tracker 

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