diff options
| author | Barry Warsaw | 2010-06-17 00:54:23 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2010-06-17 00:54:23 -0400 |
| commit | 7a147b7d1dee75f488102783550ec4f1fa36249c (patch) | |
| tree | f59274ca8244a3d57410cd682612fdba4678a43a | |
| parent | afee5d048337b31e1db35dfd5eae7dc4695e3758 (diff) | |
| download | mailman-7a147b7d1dee75f488102783550ec4f1fa36249c.tar.gz mailman-7a147b7d1dee75f488102783550ec4f1fa36249c.tar.zst mailman-7a147b7d1dee75f488102783550ec4f1fa36249c.zip | |
| -rw-r--r-- | src/mailman/rest/docs/membership.txt | 14 | ||||
| -rw-r--r-- | src/mailman/rest/members.py | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/mailman/rest/docs/membership.txt b/src/mailman/rest/docs/membership.txt index 5867c0928..0dc2771ba 100644 --- a/src/mailman/rest/docs/membership.txt +++ b/src/mailman/rest/docs/membership.txt @@ -303,3 +303,17 @@ Gwen tries to join the alpha mailing list using an invalid delivery mode. Traceback (most recent call last): ... HTTPError: HTTP Error 400: Bad Request + +Even using an address with "funny" characters Hugh can join the mailing list. + + >>> transaction.abort() + >>> dump_json('http://localhost:8001/3.0/members', { + ... 'fqdn_listname': 'alpha@example.com', + ... 'address': 'hugh/person@example.com', + ... 'real_name': 'Hugh Person', + ... }) + content-length: 0 + date: ... + location: http://localhost:8001/3.0/lists/alpha@example.com/member/hugh%2Fperson@example.com + ... + diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index 8c0593457..d9fd50e24 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -27,6 +27,7 @@ __all__ = [ from restish import http, resource +from urllib import quote from zope.component import getUtility from mailman.app.membership import delete_member @@ -115,9 +116,12 @@ class AllMembers(_MemberBase): return http.bad_request([], b'Invalid email address') except ValueError as error: return http.bad_request([], str(error)) - # wsgiref wants headers to be bytes, not unicodes. + # wsgiref wants headers to be bytes, not unicodes. Also, we have to + # quote any unsafe characters in the address. Specifically, we need + # to quote forward slashes, but not @-signs. + quoted_address = quote(member.address.address, safe=b'@') location = path_to('lists/{0}/member/{1}'.format( - member.mailing_list, member.address.address)) + member.mailing_list, quoted_address)) # Include no extra headers or body. return http.created(location, [], None) |
