------------------------------------------------------------
revno: 6684
committer: Barry Warsaw <[email protected]>
branch nick: 3.0
timestamp: Mon 2009-02-09 22:47:11 -0500
message:
  More cleanup of Utils.py on the path of its eventual demise.
  
  Move the attic and web directories out of src/mailman for easier grepping.
  Eventually these will go away.
renamed:
  src/mailman/attic => src/attic
  src/mailman/web => src/web
modified:
  src/mailman/Utils.py
  src/mailman/mta/smtp_direct.py
  src/mailman/pipeline/moderate.py

=== renamed directory 'src/mailman/attic' => 'src/attic'
=== modified file 'src/mailman/Utils.py'
--- src/mailman/Utils.py        2009-02-10 03:19:18 +0000
+++ src/mailman/Utils.py        2009-02-10 03:47:11 +0000
@@ -194,27 +194,6 @@
 
 
 
-# Patterns which may be used to form malicious path to inject a new
-# line in the mailman error log. (TK: advisory by Moritz Naumann)
-CRNLpat = re.compile(r'[^\x21-\x7e]')
-
-def GetPathPieces(envar='PATH_INFO'):
-    path = os.environ.get(envar)
-    if path:
-        if CRNLpat.search(path):
-            path = CRNLpat.split(path)[0]
-            log.error('Warning: Possible malformed path attack.')
-        return [p for p in path.split('/') if p]
-    return []
-
-
-
-def ScriptURL(target):
-    up = '../' * len(GetPathPieces())
-    return '%s%s' % (up, target + config.CGIEXT)
-
-
-
 def GetPossibleMatchingAddrs(name):
     """returns a sorted list of addresses that could possibly match
     a given name.
@@ -235,19 +214,6 @@
 
 
 
-def List2Dict(L, foldcase=False):
-    """Return a dict keyed by the entries in the list passed to it."""
-    d = {}
-    if foldcase:
-        for i in L:
-            d[i.lower()] = True
-    else:
-        for i in L:
-            d[i] = True
-    return d
-
-
-
 _vowels = ('a', 'e', 'i', 'o', 'u')
 _consonants = ('b', 'c', 'd', 'f', 'g', 'h', 'k', 'm', 'n',
                'p', 'r', 's', 't', 'v', 'w', 'x', 'z')
@@ -519,31 +485,6 @@
 
 
 
-def GetRequestURI(fallback=None, escape=True):
-    """Return the full virtual path this CGI script was invoked with.
-
-    Newer web servers seems to supply this info in the REQUEST_URI
-    environment variable -- which isn't part of the CGI/1.1 spec.
-    Thus, if REQUEST_URI isn't available, we concatenate SCRIPT_NAME
-    and PATH_INFO, both of which are part of CGI/1.1.
-
-    Optional argument `fallback' (default `None') is returned if both of
-    the above methods fail.
-
-    The url will be cgi escaped to prevent cross-site scripting attacks,
-    unless `escape' is set to 0.
-    """
-    url = fallback
-    if 'REQUEST_URI' in os.environ:
-        url = os.environ['REQUEST_URI']
-    elif 'SCRIPT_NAME' in os.environ and 'PATH_INFO' in os.environ:
-        url = os.environ['SCRIPT_NAME'] + os.environ['PATH_INFO']
-    if escape:
-        return websafe(url)
-    return url
-
-
-
 # XXX Replace this with direct calls.  For now, existing uses of GetCharSet()
 # are too numerous to change.
 def GetCharSet(lang):
@@ -551,20 +492,6 @@
 
 
 
-def get_request_domain():
-    host = os.environ.get('HTTP_HOST', os.environ.get('SERVER_NAME'))
-    port = os.environ.get('SERVER_PORT')
-    # Strip off the port if there is one
-    if port and host.endswith(':' + port):
-        host = host[:-len(port)-1]
-    return host.lower()
-
-
-def get_site_noreply():
-    return '%...@%s' % (config.NO_REPLY_ADDRESS, config.DEFAULT_EMAIL_HOST)
-
-
-
 # Figure out epoch seconds of midnight at the start of today (or the given
 # 3-tuple date of (year, month, day).
 def midnight(date=None):

=== modified file 'src/mailman/mta/smtp_direct.py'
--- src/mailman/mta/smtp_direct.py      2009-02-10 03:19:18 +0000
+++ src/mailman/mta/smtp_direct.py      2009-02-10 03:47:11 +0000
@@ -114,7 +114,7 @@
         if mlist:
             envsender = mlist.bounces_address
         else:
-            envsender = Utils.get_site_noreply()
+            envsender = config.mailman.site_owner
     # Time to split up the recipient list.  If we're personalizing or VERPing
     # then each chunk will have exactly one recipient.  We'll then hand craft
     # an envelope sender and stitch a message together in memory for each one

=== modified file 'src/mailman/pipeline/moderate.py'
--- src/mailman/pipeline/moderate.py    2009-02-10 03:19:18 +0000
+++ src/mailman/pipeline/moderate.py    2009-02-10 03:47:11 +0000
@@ -122,21 +122,21 @@
 
 
 def matches_p(sender, nonmembers):
-    # First strip out all the regular expressions
-    plainaddrs = [addr for addr in nonmembers if not addr.startswith('^')]
-    addrdict = Utils.List2Dict(plainaddrs, foldcase=1)
-    if addrdict.has_key(sender):
-        return 1
-    # Now do the regular expression matches
-    for are in nonmembers:
-        if are.startswith('^'):
+    # First strip out all the regular expressions.
+    addresses = set(address.lower() for address in nonmembers
+                    if not address.startswith('^'))
+    if sender in addresses:
+        return True
+    # Now do the regular expression matches.
+    for regexp in nonmembers:
+        if regexp.startswith('^'):
             try:
-                cre = re.compile(are, re.IGNORECASE)
+                cre = re.compile(regexp, re.IGNORECASE)
             except re.error:
                 continue
             if cre.search(sender):
-                return 1
-    return 0
+                return True
+    return False
 
 
 

=== renamed directory 'src/mailman/web' => 'src/web'


--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to