Mercurial > cpython-lru_cache-weakref
diff Lib/email/_parseaddr.py @ 65062:ef5c57217b20
#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.
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Sat, 02 Oct 2010 15:58:26 +0000 |
| parents | 87bdf53ff4bb |
| children | 9385c536f454 |
line wrap: on
line diff
--- a/Lib/email/_parseaddr.py Sat Oct 02 13:29:13 2010 +0000 +++ b/Lib/email/_parseaddr.py Sat Oct 02 15:58:26 2010 +0000 @@ -160,7 +160,12 @@ 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 @@ 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:
