summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2003-03-11 18:18:53 +0000
committerbwarsaw2003-03-11 18:18:53 +0000
commitd3ffcb9ae13e6229a11980ace6221a1931aa3ca1 (patch)
tree639dc7ab43ffc7a1880477612b3d9dde1db3b392
parentae6b9b101a80078fd01ff428581773527c796e1f (diff)
downloadmailman-d3ffcb9ae13e6229a11980ace6221a1931aa3ca1.tar.gz
mailman-d3ffcb9ae13e6229a11980ace6221a1931aa3ca1.tar.zst
mailman-d3ffcb9ae13e6229a11980ace6221a1931aa3ca1.zip
More fixes for "funny" characters in real names.
-rwxr-xr-xbin/list_members22
1 files changed, 15 insertions, 7 deletions
diff --git a/bin/list_members b/bin/list_members
index 3ad10f516..3306b2e94 100755
--- a/bin/list_members
+++ b/bin/list_members
@@ -1,6 +1,6 @@
#! @PYTHON@
#
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -61,6 +61,7 @@ status.
"""
import sys
+from types import UnicodeType
import paths
from Mailman import mm_cfg
@@ -72,6 +73,8 @@ from Mailman.i18n import _
from email.Utils import formataddr
PROGRAM = sys.argv[0]
+ENC = sys.getdefaultencoding()
+
WHYCHOICES = {'enabled' : MemberAdaptor.ENABLED,
'unknown' : MemberAdaptor.UNKNOWN,
'byuser' : MemberAdaptor.BYUSER,
@@ -92,6 +95,15 @@ def usage(code, msg=''):
+def safe(addr):
+ if addr is None:
+ return ''
+ if isinstance(addr, UnicodeType):
+ return addr.encode(ENC, 'replace')
+ return unicode(addr, ENC, 'replace').encode(ENC, 'replace')
+
+
+
def whymatches(mlist, addr, why):
# Return true if the `why' matches the reason the address is enabled, or
# in the case of why is None, that they are disabled for any reason
@@ -203,9 +215,7 @@ def main():
# Filter out nomails
if nomail and not whymatches(mlist, addr, why):
continue
- enc = sys.getdefaultencoding()
- s = formataddr((name, addr)).encode(enc, 'replace')
- print >> fp, s
+ print >> fp, formataddr((safe(name), addr))
if digest:
dmembers.sort()
for addr in dmembers:
@@ -222,9 +232,7 @@ def main():
# They're getting MIME digests
if kind == 'plain':
continue
- enc = sys.getdefaultencoding()
- s = formataddr((name, addr)).encode(enc, 'replace')
- print >> fp, s
+ print >> fp, formataddr((safe(name), addr))