summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/Defaults.py.in9
-rw-r--r--Mailman/MailCommandHandler.py8
-rw-r--r--Mailman/MailList.py9
-rw-r--r--Mailman/Utils.py51
4 files changed, 32 insertions, 45 deletions
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
index 45a88301d..4307298c4 100644
--- a/Mailman/Defaults.py.in
+++ b/Mailman/Defaults.py.in
@@ -62,7 +62,14 @@ MAX_SPAWNS = 40
USE_CRYPT = 1
# General Defaults #
-
+#
+# if this is set to 1, then mailman will consider user@host.domain as
+# the same address as user@domain. if it is set to 0, mailman will consider
+# user@host.domain the same address as user@Host.DoMain, but different
+# than user@domain. usernames will be case preserved, host parts of addresses
+# will all be lowercased.
+#
+SMART_ADDRESS_MATCH = 1
DEFAULT_FILTER_PROG = ''
# Default number of batches in which to divide large deliveries:
DEFAULT_NUM_SPAWNS = 5
diff --git a/Mailman/MailCommandHandler.py b/Mailman/MailCommandHandler.py
index 9ef4a5c42..7702eae82 100644
--- a/Mailman/MailCommandHandler.py
+++ b/Mailman/MailCommandHandler.py
@@ -84,6 +84,10 @@ class MailCommandHandler:
mail = Message.IncomingMessage()
subject = mail.getheader("subject")
sender = string.lower(mail.GetSender())
+ #
+ # shouldn't this be checking the username only part?
+ # why 'orphanage'?
+ #
if sender in ['daemon', 'nobody', 'mailer-daemon', 'postmaster',
'orphanage', 'postoffice']:
# This is for what are probably delivery-failure notices of
@@ -433,7 +437,7 @@ class MailCommandHandler:
digest = 0
done_digest = 1
elif string.lower(arg)[:8] == 'address=' and not address:
- address = string.lower(arg)[8:]
+ address = Utils.LCDomain(arg[8:])
elif not password:
password = arg
else:
@@ -445,7 +449,7 @@ class MailCommandHandler:
password = "%s%s" % (Utils.GetRandomSeed(),
Utils.GetRandomSeed())
if not address:
- subscribe_address = string.lower(mail.GetSender())
+ subscribe_address = Utils.LCDomain(mail.GetSender())
else:
subscribe_address = address
remote = mail.GetSender()
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 6ef9e9c0c..82a12efd4 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -681,7 +681,9 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin,
def AddMember(self, name, password, digest=0, remote=None):
self.IsListInitialized()
# Remove spaces... it's a common thing for people to add...
- name = string.join(string.split(string.lower(name)), '')
+ name = string.join(string.split(name), '')
+ # lower case only the domain part
+ name = Utils.LCDomain(name)
# Validate the e-mail address to some degree.
if not Utils.ValidEmail(name):
@@ -739,15 +741,12 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin,
def ApprovedAddMember(self, name, password, digest, ack=None):
- # XXX klm: It *might* be nice to leave the case of the name alone,
- # but provide a common interface that always returns the
- # lower case version for computations.
if ack is None:
if self.send_welcome_msg:
ack = 1
else:
ack = 0
- name = string.lower(name)
+ name = Utils.LCDomain(name)
if self.IsMember(name):
raise Errors.MMAlreadyAMember
if digest:
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index cd4e6d961..88f2ea5c7 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -33,31 +33,6 @@ import fcntl
import random
import mm_cfg
-# Valid toplevel domains for when we check the validity of an email address.
-
-valid_toplevels = ["com", "edu", "gov", "int", "mil", "net", "org",
-"inc", "af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar",
-"am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be",
-"bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn",
-"bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl",
-"cn", "cx", "cc", "co", "km", "cg", "ck", "cr", "ci", "hr", "cu",
-"cy", "cz", "dk", "dj", "dm", "do", "tp", "ec", "eg", "sv", "gq",
-"ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga",
-"gm", "ge", "de", "gh", "gi", "gb", "uk", "gr", "gl", "gd", "gp",
-"gu", "gt", "gn", "gw", "gy", "ht", "hm", "hn", "hk", "hu", "is",
-"in", "id", "ir", "iq", "ie", "il", "it", "jm", "jp", "jo", "kz",
-"ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr",
-"ly", "li", "lt", "lu", "mo", "mg", "mw", "my", "mv", "ml", "mt",
-"mh", "mq", "mr", "mu", "mx", "fm", "md", "mc", "mn", "ms", "ma",
-"mz", "mm", "na", "nr", "np", "an", "nl", "nt", "nc", "nz", "ni",
-"ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "pa", "pg",
-"py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru",
-"rw", "kn", "lc", "vc", "sm", "st", "sa", "sn", "sc", "sl", "sg",
-"sk", "si", "sb", "so", "za", "es", "lk", "sh", "pm", "sd", "sr",
-"sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tg", "tk",
-"to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "um", "us",
-"uy", "uz", "vu", "va", "ve", "vn", "vg", "vi", "wf", "eh", "ws",
-"ye", "yu", "zr", "zm", "zw", "su"]
def list_names():
"""Return the names of all lists in default list directory."""
@@ -253,20 +228,10 @@ def ValidEmail(str):
return 1
if len(domain_parts) < 2:
return 0
-## if domain_parts[-1] not in valid_toplevels:
-## if len(domain_parts) <> 4:
-## return 0
-## try:
-## domain_parts = map(eval, domain_parts)
-## except:
-## return 0
-## for i in domain_parts:
-## if i < 0 or i > 255:
-## return 0
return 1
-#
+
def GetPathPieces(path):
l = string.split(path, '/')
try:
@@ -320,12 +285,24 @@ def ParseEmail(email):
domain = string.split(rest, '.')
return (user, domain)
+
+def LCDomain(addr):
+ "returns the address with the domain part lowercased"
+ atind = string.find(addr, '@')
+ if atind == -1: # no domain part
+ return addr
+ return addr[:atind] + '@' + string.lower(addr[atind + 1:])
+
+
+
# Return 1 if the 2 addresses match. 0 otherwise.
# Might also want to match if there's any common domain name...
# There's password protection anyway.
-
def AddressesMatch(addr1, addr2):
"True when username matches and host addr of one addr contains other's."
+ addr1, addr2 = map(LCDomain, [addr1, addr2])
+ if not mm_cfg.SMART_ADDRESS_MATCH:
+ return addr1 == addr2
user1, domain1 = ParseEmail(addr1)
user2, domain2 = ParseEmail(addr2)
if user1 != user2: