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: email/quoprimime.py Exception (with patch)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: guettli, r.david.murray
Priority: normal Keywords: patch

Created on 2010-10-01 11:05 by guettli, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
quoprimime.py.diff guettli, 2010-10-01 11:05 patch of the regex which feeds strings to int(..., 16)
broken-subject.msg guettli, 2010-10-01 11:10 Message to reproduce the bug
quoprime_chars.patch r.david.murray, 2010-10-01 15:27
Messages (4)
msg117784 - (view) Author: Thomas Guettler (guettli) * Date: 2010-10-01 11:05
I get the following traceback. I created a patch against email/quoprimime.py from SVN branch python2.7

  File "/usr/lib64/python2.6/email/header.py", line 93, in decode_header
    dec = email.quoprimime.header_decode(encoded)
  File "/usr/lib64/python2.6/email/quoprimime.py", line 336, in header_decode
    return re.sub(r'=\w{2}', _unquote_match, s)
  File "/usr/lib64/python2.6/re.py", line 150, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib64/python2.6/email/quoprimime.py", line 324, in _unquote_match
    return unquote(s)
  File "/usr/lib64/python2.6/email/quoprimime.py", line 106, in unquote
    return chr(int(s[1:3], 16))
ValueError: invalid literal for int() with base 16: 'ih'
msg117807 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-01 15:04
Heh, cut and paste gone mad, sorry about that title change/change back.

I can reproduce this in 3.2, so adding 3.1 and 3.2 to versions.
msg117808 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-01 15:27
Here is Thomas's patch with a (simpler) unit test included.
msg117809 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-01 15:49
Committed in r85142 for 3.2, r85143 for 3.1, and r85144 for 2.7.

Thanks, Thomas.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54213
2010-10-01 15:49:41r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg117809

stage: test needed -> resolved
2010-10-01 15:27:59r.david.murraysetfiles: + quoprime_chars.patch

messages: + msg117808
2010-10-01 15:09:44r.david.murraysetassignee: r.david.murray
2010-10-01 15:05:26r.david.murraysettype: behavior
stage: test needed
2010-10-01 15:04:47r.david.murraysetnosy: + r.david.murray

messages: + msg117807
versions: + Python 3.1, Python 3.2
2010-10-01 15:04:04r.david.murraysettitle: irhe -> email/quoprimime.py Exception (with patch)
2010-10-01 15:03:34r.david.murraysettitle: email/quoprimime.py Exception (with patch) -> irhe
2010-10-01 11:10:26guettlisetfiles: + broken-subject.msg
2010-10-01 11:05:46guettlicreate