homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Thinko in Lib/quopri.py, decoding b"==" to b"="
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, martin.panter, orsenthil, pfalcon, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: easy, patch

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:03adminsetgithub: 65710
2015年04月11日 22:31:43r.david.murraysetstatus: open -> closed
stage: test needed -> resolved
2015年04月11日 21:48:00gvanrossumsetresolution: fixed
dependencies: - Inconsistency between quopri.decodestring() and email.quoprimime.decode()
messages: + msg240499
2015年04月11日 21:46:09python-devsetnosy: + python-dev
messages: + msg240497
2015年04月11日 21:39:37gvanrossumsetfiles: + fix_issue_21511.diff

nosy: + gvanrossum
messages: + msg240496

keywords: + patch
2015年03月24日 12:06:38berker.peksagsetkeywords: + easy
2015年03月24日 08:00:46martin.pantersetnosy: + martin.panter

messages: + msg239095
title: Thinko in Lib/quopri.py -> Thinko in Lib/quopri.py, decoding b"==" to b"="
2014年05月16日 20:05:02r.david.murraysetmessages: + msg218681
2014年05月16日 19:49:26pfalconsetmessages: + msg218680
2014年05月16日 19:22:01r.david.murraysetdependencies: + Inconsistency between quopri.decodestring() and email.quoprimime.decode()
messages: + msg218679
2014年05月16日 19:16:40terry.reedysetversions: + Python 3.4
nosy: + terry.reedy, r.david.murray, orsenthil

messages: + msg218678

stage: test needed
2014年05月15日 16:37:35pfalconcreate

AltStyle によって変換されたページ (->オリジナル) /