[issue28945] get_boundary invokes unquote twice

Eric Lafontaine report at bugs.python.org
Tue Dec 20 11:21:22 EST 2016


Eric Lafontaine added the comment:

Hi all,

I hate this proposition.  I feel it's a "victory" for the people who don't want to follow RFC standard and allow "triple"-quoting on things that aren't supposed to...

Now that my opinion is said, I made 2 test case that should be added to the test_email file of the test library to support the change :

_________________________________________________________
    def test_rfc2231_multiple_quote_boundary(self):
        m = '''\
Content-Type: multipart/alternative;
\tboundary*0*="<<This%20is%20even%20more%20";
\tboundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
\tboundary*2="is it not.pdf>>"

'''
        msg = email.message_from_string(m)
        self.assertEqual(msg.get_boundary(),
                         '<<This is even more ***fun*** is it not.pdf>>')
    def test_rfc2231_multiple_quote_boundary2(self):
        m = '''\
Content-Type: multipart/alternative;
\tboundary="<<This is even more >>";

'''
        msg = email.message_from_string(m)
        self.assertEqual(msg.get_boundary(),
                         '<<This is even more >>')
_______________________________________________________

The problem however does lie within collapse function as you've mentionned (because you've taken the code from there haven't you? :P) :
def collapse_rfc2231_value(value, errors='replace',
                           fallback_charset='us-ascii'):
    if not isinstance(value, tuple) or len(value) != 3:
        return value                                     <=======removed unquote on value
        
 This doesn't seem to have broken any of the 1580 tests case of test_email (Python3.7), but I can't help but to feel weird about it.  Could someone explain why we were unquoting there? and why use those weird condition (not isintance(value,tuple) or len(value) !=3)....?
 
 Regards,
 Eric Lafontaine

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28945>
_______________________________________


More information about the Python-bugs-list mailing list