mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
#1050268: make parseaddr 'quote' the contents of quoted strings in addresses.
Also made the doc string for email._parseaddr's 'quote' function more accurate; I'd love to make the function match the old docstring instead, but other code uses it according the existing semantics.
This commit is contained in:
parent
8f7bcb3f85
commit
5397e862e2
3 changed files with 28 additions and 2 deletions
|
|
@ -160,7 +160,12 @@ def mktime_tz(data):
|
|||
|
||||
|
||||
def quote(str):
|
||||
"""Add quotes around a string."""
|
||||
"""Prepare string to be used in a quoted string.
|
||||
|
||||
Turns backslash and double quote characters into quoted pairs. These
|
||||
are the only characters that need to be quoted inside a quoted string.
|
||||
Does not add the surrounding double quotes.
|
||||
"""
|
||||
return str.replace('\\', '\\\\').replace('"', '\\"')
|
||||
|
||||
|
||||
|
|
@ -318,7 +323,7 @@ class AddrlistClass:
|
|||
aslist.append('.')
|
||||
self.pos += 1
|
||||
elif self.field[self.pos] == '"':
|
||||
aslist.append('"%s"' % self.getquote())
|
||||
aslist.append('"%s"' % quote(self.getquote()))
|
||||
elif self.field[self.pos] in self.atomends:
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue