mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
#12818: remove escaping of () in quoted strings in formataddr
The quoting of ()s inside quoted strings is allowed by the RFC, but is not needed. There seems to be no reason to add needless escapes.
This commit is contained in:
parent
345266aa7e
commit
b53319f509
3 changed files with 17 additions and 2 deletions
|
|
@ -2702,7 +2702,10 @@ class TestMiscellaneous(TestEmailBase):
|
|||
def test_escape_dump(self):
|
||||
self.assertEqual(
|
||||
utils.formataddr(('A (Very) Silly Person', 'person@dom.ain')),
|
||||
r'"A \(Very\) Silly Person" <person@dom.ain>')
|
||||
r'"A (Very) Silly Person" <person@dom.ain>')
|
||||
self.assertEqual(
|
||||
utils.parseaddr(r'"A \(Very\) Silly Person" <person@dom.ain>'),
|
||||
('A (Very) Silly Person', 'person@dom.ain'))
|
||||
a = r'A \(Special\) Person'
|
||||
b = 'person@dom.ain'
|
||||
self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
|
||||
|
|
@ -2800,6 +2803,15 @@ class TestMiscellaneous(TestEmailBase):
|
|||
self.assertEqual(('', 'merwok.wok.wok@xample.com'),
|
||||
utils.parseaddr('merwok. wok . wok@xample.com'))
|
||||
|
||||
def test_formataddr_does_not_quote_parens_in_quoted_string(self):
|
||||
addr = ("'foo@example.com' (foo@example.com)",
|
||||
'foo@example.com')
|
||||
addrstr = ('"\'foo@example.com\' '
|
||||
'(foo@example.com)" <foo@example.com>')
|
||||
self.assertEqual(utils.parseaddr(addrstr), addr)
|
||||
self.assertEqual(utils.formataddr(addr), addrstr)
|
||||
|
||||
|
||||
def test_multiline_from_comment(self):
|
||||
x = """\
|
||||
Foo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue