Bug report
Bug description:
Issue
email.quoprimime.decode() strips only one character when removing a trailing line ending that wasn't in the original input. When eol='\r\n' (2 characters), only the \n is removed, leaving a stray \r.
The bug is in this line:
decoded = decoded[:-1]
It should be decoded[:-len(eol)].
Reproducer
import email.quoprimime as qp print(repr(qp.decode('abc', eol='\r\n'))) # 'abc\r' โ expected 'abc' print(repr(qp.decode('a\nb', eol='\r\n'))) # 'a\r\nb\r' โ trailing \r is spurious
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response