diff options
| author | R. David Murray <rdmurray@bitdance.com> | 2010-10-02 16:26:05 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2010-10-02 16:26:05 (GMT) |
| commit | 10a867669193c942e5ad3da9da0b6bcc5b493c17 (patch) | |
| tree | f36a1826df7d416cad49dc4f1db3048f4d3aadfd /Lib/email/_parseaddr.py | |
| parent | 452b0ce586582d9368e56fab96f686ce775995ae (diff) | |
| download | cpython-10a867669193c942e5ad3da9da0b6bcc5b493c17.zip cpython-10a867669193c942e5ad3da9da0b6bcc5b493c17.tar.gz cpython-10a867669193c942e5ad3da9da0b6bcc5b493c17.tar.bz2 | |
Merged revisions 85179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85179 | r.david.murray | 2010-10-02 11:58:26 -0400 (Sat, 02 Oct 2010) | 6 lines
#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.
........
Diffstat (limited to 'Lib/email/_parseaddr.py')
| -rw-r--r-- | Lib/email/_parseaddr.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index ac2e524..3bd4ba4 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -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: |
