diff options
author | Mark Sapiro <mark@msapiro.net> | 2019-03-01 18:24:14 -0800 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2019-03-01 18:24:14 -0800 |
commit | d42ff460f48550f01b7cf97935df4bcdfb829373 (patch) | |
tree | 8f70ea1c5ea7f69dcda606eb9b6f338edc74d222 /Mailman/Utils.py | |
parent | dd5dc51fc773b56c6f4b33ab739d2b148ec45337 (diff) | |
download | mailman2-d42ff460f48550f01b7cf97935df4bcdfb829373.tar.gz mailman2-d42ff460f48550f01b7cf97935df4bcdfb829373.tar.xz mailman2-d42ff460f48550f01b7cf97935df4bcdfb829373.zip |
Implement MAX_LISTNAME_LENGTH to avoid calculating on each web access.
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r-- | Mailman/Utils.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 47e4e5cc..10629fc4 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -292,11 +292,16 @@ def GetPathPieces(envar='PATH_INFO'): remote) # Check for listname injections that won't be websafed. pieces = [p for p in path.split('/') if p] - # Get the longest listname or 20 if none. - if list_names(): - longest = max([len(x) for x in list_names()]) + # Get the longest listname or 20 if none or use MAX_LISTNAME_LENGTH if + # provided > 0. + if mm_cfg.MAX_LISTNAME_LENGTH > 0: + longest = mm_cfg.MAX_LISTNAME_LENGTH else: - longest = 20 + lst_names = list_names() + if lst_names: + longest = max([len(x) for x in lst_names]) + else: + longest = 20 if pieces and len(pieces[0]) > longest: syslog('mischief', 'Hostile listname: listname=%s: remote=%s', pieces[0], remote) |