Issue 21511: Thinko in Lib/quopri.py, decoding b"==" to b"=" (original) (raw)

Created on 2014-05-15 16:37 by pfalcon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_issue_21511.diff gvanrossum,2015-04-11 21:39 unittest by CW review
Messages (9)
msg218618 - (view) Author: Paul Sokolovsky (pfalcon) * Date: 2014-05-15 16:37
Lib/quopri.py for version 3.3..3.5-tip contains following code: ESCAPE = b'=' ... line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1:n] == b'\n': ... elif i+1 < n and line[i+1] == ESCAPE: So, ESCAPE is defined as bytes, we see that "line" is read as bytes, and characters are accessed using idiom like "line[n-1:n]", but then it uses "line[i+1]", which returns int and thus will never be equal to ESCAPE. I'm not sure what exact semantic condition that branch represents, for me it looks like "==" sequence to be decoded as "=". But I don't see such encoding variant in http://en.wikipedia.org/wiki/Quoted-printable . Either way, replacing that condition with "and False", still passes test_quopri.py
msg218678 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-16 19:16
Senthil, David, I hope one of you understands this. I looks like a minor fix.
msg218679 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-16 19:22
We should resolve issue 18022 before we decide how to "fix" this.
msg218680 - (view) Author: Paul Sokolovsky (pfalcon) * Date: 2014-05-16 19:49
This is minor issue indeed, uncovered when trying to run quopri.py with MicroPython http://micropython.org . I now worked around this on MicroPython side, but otherwise I set to report any issues I've seen with MicroPython porting, in the hope that MicroPython effort is good member of Python community. If the original report is unclear, feel free to point to any vague spots, and I'll elaborate on it. Thanks.
msg218681 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-16 20:05
Thanks. It's very clear. What isn't clear is if the line should be made to work as apparently intended, or removed :) (My guess at this point without re-reading the RFCs is that it should be removed.)
msg239095 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-03-24 08:00
The implementation has been fixed for Issue 23681 to slice instead of index, and now compares byte strings: >>> import quopri >>> quopri.decodestring(b"123==four") b'123=four' >>> quopri.a2b_qp = None >>> quopri.decodestring(b"123==four") b'123=four' However, I think a test still needs to be written to cover this branch of the code.
msg240496 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-04-11 21:39
Here's a unittest by Christie Wilson for this issue.
msg240497 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-04-11 21:46
New changeset 2582962ccf17 by Guido van Rossum in branch '3.4': Unittest for Issue 21511 by Christie Wilson bobcatfish@gmail.com. https://hg.python.org/cpython/rev/2582962ccf17 New changeset 23d37a147051 by Guido van Rossum in branch 'default': Unittest for Issue 21511 by Christie Wilson bobcatfish@gmail.com (merge from 3.4). https://hg.python.org/cpython/rev/23d37a147051
msg240499 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-04-11 21:48
Fixed, and removing the dependency on issue 18022. Thanks Christie!
History
Date User Action Args
2022-04-11 14:58:03 admin set github: 65710
2015-04-11 22:31:43 r.david.murray set status: open -> closedstage: test needed -> resolved
2015-04-11 21:48:00 gvanrossum set resolution: fixeddependencies: - Inconsistency between quopri.decodestring() and email.quoprimime.decode()messages: +
2015-04-11 21:46:09 python-dev set nosy: + python-devmessages: +
2015-04-11 21:39:37 gvanrossum set files: + fix_issue_21511.diffnosy: + gvanrossummessages: + keywords: + patch
2015-03-24 12:06:38 berker.peksag set keywords: + easy
2015-03-24 08:00:46 martin.panter set nosy: + martin.pantermessages: + title: Thinko in Lib/quopri.py -> Thinko in Lib/quopri.py, decoding b"==" to b"="
2014-05-16 20:05:02 r.david.murray set messages: +
2014-05-16 19:49:26 pfalcon set messages: +
2014-05-16 19:22:01 r.david.murray set dependencies: + Inconsistency between quopri.decodestring() and email.quoprimime.decode()messages: +
2014-05-16 19:16:40 terry.reedy set versions: + Python 3.4nosy: + terry.reedy, r.david.murray, orsenthilmessages: + stage: test needed
2014-05-15 16:37:35 pfalcon create