~launchpad-pqm/mailman/2.1

« back to all changes in this revision

Viewing changes to Mailman/MailList.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2009-10-21 01:06:17 UTC
  • mfrom: (975.1.1 mailman.2112)
  • Revision ID: launchpad@pqm.canonical.com-20091021010617-prbs2ay6nhxx515v
[rs=flacoste] Upgrade Mailman to upstream 2.1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
2
2
#
3
3
# This program is free software; you can redistribute it and/or
4
4
# modify it under the terms of the GNU General Public License
337
337
        self.umbrella_list = mm_cfg.DEFAULT_UMBRELLA_LIST
338
338
        self.umbrella_member_suffix = \
339
339
                mm_cfg.DEFAULT_UMBRELLA_MEMBER_ADMIN_SUFFIX
 
340
        self.regular_exclude_lists = mm_cfg.DEFAULT_REGULAR_EXCLUDE_LISTS
 
341
        self.regular_include_lists = mm_cfg.DEFAULT_REGULAR_INCLUDE_LISTS
340
342
        self.send_reminders = mm_cfg.DEFAULT_SEND_REMINDERS
341
343
        self.send_welcome_msg = mm_cfg.DEFAULT_SEND_WELCOME_MSG
342
344
        self.send_goodbye_msg = mm_cfg.DEFAULT_SEND_GOODBYE_MSG
470
472
    #
471
473
    def Create(self, name, admin, crypted_password,
472
474
               langs=None, emailhost=None):
 
475
        assert name == name.lower(), 'List name must be all lower case.'
473
476
        if Utils.list_exists(name):
474
477
            raise Errors.MMListAlreadyExistsError, name
 
478
        # Problems and potential attacks can occur if the list name in the
 
479
        # pipe to the wrapper in an MTA alias or other delivery process
 
480
        # contains shell special characters so allow only defined characters
 
481
        # (default = '[-+_.=a-z0-9]').
 
482
        if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', name)) > 0:
 
483
            raise Errors.BadListNameError, name
475
484
        # Validate what will be the list's posting address.  If that's
476
485
        # invalid, we don't want to create the mailing list.  The hostname
477
486
        # part doesn't really matter, since that better already be valid.
482
491
        postingaddr = '%s@%s' % (name, emailhost)
483
492
        try:
484
493
            Utils.ValidateEmail(postingaddr)
485
 
        except Errors.MMBadEmailError:
 
494
        except Errors.EmailAddressError:
486
495
            raise Errors.BadListNameError, postingaddr
487
496
        # Validate the admin's email address
488
497
        Utils.ValidateEmail(admin)
1062
1071
        newaddr = Utils.LCDomain(newaddr)
1063
1072
        Utils.ValidateEmail(newaddr)
1064
1073
        # Raise an exception if this email address is already a member of the
1065
 
        # list, but only if the new address is the same case-wise as the old
1066
 
        # address and we're not doing a global change.
1067
 
        if not globally and newaddr == oldaddr and self.isMember(newaddr):
 
1074
        # list, but only if the new address is the same case-wise as the
 
1075
        # existing member address and we're not doing a global change.
 
1076
        if not globally and (self.isMember(newaddr) and
 
1077
                newaddr == self.getMemberCPAddress(newaddr)):
1068
1078
            raise Errors.MMAlreadyAMember
1069
1079
        if newaddr == self.GetListEmail().lower():
1070
1080
            raise Errors.MMBadEmailError
1120
1130
            raise Errors.MembershipIsBanned, pattern
1121
1131
        # It's possible they were a member of this list, but choose to change
1122
1132
        # their membership globally.  In that case, we simply remove the old
1123
 
        # address.
1124
 
        if self.getMemberCPAddress(oldaddr) == newaddr:
1125
 
            self.removeMember(oldaddr)
 
1133
        # address.  This gets tricky with case changes.  We can't just remove
 
1134
        # the old address if it differs from the new only by case, because
 
1135
        # that removes the new, so the condition is if the new address is the
 
1136
        # CP address of a member, then if the old address yields a different
 
1137
        # CP address, we can simply remove the old address, otherwise we can
 
1138
        # do nothing.
 
1139
        if self.isMember(newaddr) and (self.getMemberCPAddress(newaddr) ==
 
1140
                newaddr):
 
1141
            if self.getMemberCPAddress(oldaddr) <> newaddr:
 
1142
                self.removeMember(oldaddr)
1126
1143
        else:
1127
1144
            self.changeMemberAddress(oldaddr, newaddr)
1128
1145
        # If globally is true, then we also include every list for which
1144
1161
            mlist.Lock()
1145
1162
            try:
1146
1163
                # Same logic as above, re newaddr is already a member
1147
 
                if mlist.getMemberCPAddress(oldaddr) == newaddr:
1148
 
                    mlist.removeMember(oldaddr)
 
1164
                if mlist.isMember(newaddr) and (
 
1165
                        mlist.getMemberCPAddress(newaddr) == newaddr):
 
1166
                    if mlist.getMemberCPAddress(oldaddr) <> newaddr:
 
1167
                        mlist.removeMember(oldaddr)
1149
1168
                else:
1150
1169
                    mlist.changeMemberAddress(oldaddr, newaddr)
1151
1170
                mlist.Save()