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.

Author r.david.murray
Recipients Jeremy.Hylton, barry, gvanrossum, martin.panter, r.david.murray, serhiy.storchaka
Date 2018-05-14.19:41:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526326873.26.0.682650639539.issue18022@psf.upfronthosting.co.za>
In-reply-to
Content
OK, I've finally gotten around to looking at this.   It looks like quopri and binascii are not stripping trailing whitespace.

              quoprimime  binascii     quopri       preferred

 b'='         ''          b''          b'='         '='
 b'= '        ''          b'= '        b'= '        '='
 b'= \n'      ''          b'= \n'      b''                quoprimime  binascii  quopri

 b'='      ''          b''       b'='
 b'= '     ''          b'= '     b'= '
 b'= \n'   ''          b'= \n'   b''
 b'=\r'    ''          b''       b'=\r'
 b'==41'   '=A'        b'=41'    b'=41'    '=\n'
 b'=\r'       ''          b''          b'=\r'       '=\r'
 b'==41'      '=A'        b'=41'       b'=41'       '=A'
 b'= \n f\n'  ' f\n'      b'= \n f\n'  b'= \n f\n'  ' f\n'

The RFC recommends that a trailing = be preserved, but that trailing whitespace be ignored.  It doesn't speak directly to the ==41 case, but one can infer that the first = in the == pair is most likely to have "come from the source text" and not been encoded, while the =41 was an intentional encoding and so should be decoded.

Now, that said, the actual behavior that our libraries have had for a long time is to treat the "last line" just like all other lines, and strip a trailing =.  So I would be inclined to keep that behavior for backward compatibility reasons rather than change it to be more RFC compliant, given that we don't have any actual bug report related to it, and "fixing" it could break things.  Given that, the current quoprimime behavior becomes the reference.

However, backward compatibility concerns also arise around starting to strip trailing space in quopri and binascii. Maybe we only make that change in 3.8?
History
Date User Action Args
2018-05-14 19:41:13r.david.murraysetrecipients: + r.david.murray, gvanrossum, barry, Jeremy.Hylton, martin.panter, serhiy.storchaka
2018-05-14 19:41:13r.david.murraysetmessageid: <1526326873.26.0.682650639539.issue18022@psf.upfronthosting.co.za>
2018-05-14 19:41:13r.david.murraylinkissue18022 messages
2018-05-14 19:41:13r.david.murraycreate