You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2016/11/06 01:20:54 UTC
incubator-ponymail git commit: import-mbox.py allows invalid lid
Repository: incubator-ponymail
Updated Branches:
refs/heads/master a9457f3ca -> 96be36c7a
import-mbox.py allows invalid lid
This fixes #230
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/96be36c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/96be36c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/96be36c7
Branch: refs/heads/master
Commit: 96be36c7ac54f921ffa35c84721081829cf86a9c
Parents: a9457f3
Author: Sebb <se...@apache.org>
Authored: Sun Nov 6 01:19:02 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sun Nov 6 01:20:35 2016 +0000
----------------------------------------------------------------------
tools/archiver.py | 16 ++++++++++------
tools/import-mbox.py | 4 ++--
2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/96be36c7/tools/archiver.py
----------------------------------------------------------------------
diff --git a/tools/archiver.py b/tools/archiver.py
index 0f422cd..18ac3d2 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -108,6 +108,15 @@ def pm_charsets(msg):
charsets.update([c])
return charsets
+def normalize_lid(lid):
+ """ Ensure that a lid is in standard form, i.e. <a.b.c.d> """
+ # first drop any leading or trailing chars
+ m = re.search(r"<(.+)>", lid)
+ if m:
+ lid = m.group(1)
+ # Belt-and-braces: remove possible extraneous chars
+ return "<%s>" % lid.strip(" <>").replace("@", ".")
+
class Archiver(object):
""" A mailman 3 archiver that forwards messages to pony mail. """
if config.has_section('mailman') and config.has_option('mailman', 'plugin'):
@@ -344,12 +353,7 @@ class Archiver(object):
:param msg: The message object.
"""
- lid = None
- m = re.search(r"(<.+>)", mlist.list_id.replace("@", "."))
- if m:
- lid = m.group(1)
- else:
- lid = "<%s>" % mlist.list_id.strip("<>").replace("@", ".")
+ lid = normalize_lid(mlist.list_id)
private = False
if hasattr(mlist, 'archive_public') and mlist.archive_public == True:
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/96be36c7/tools/import-mbox.py
----------------------------------------------------------------------
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index c2e2c62..0171f54 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -393,7 +393,7 @@ if args.source:
if args.dir:
maildir = args.dir
if args.listid:
- list_override = '<%s>' % args.listid[0].strip('<>')
+ list_override = archiver.normalize_lid(args.listid[0])
if args.project:
project = args.project[0]
if args.domain:
@@ -431,7 +431,7 @@ def globDir(d):
print("Would you like to set a list-ID override for %s?:" % d)
lo = sys.stdin.readline()
if lo and len(lo) > 3:
- fileToLID[d] = "<" + lo.strip("\r\n<>") + ">"
+ fileToLID[d] = archiver.normalize_lid(lo.strip("\r\n"))
print("Righto, setting it to %s." % fileToLID[d])
else:
print("alright, I'll try to figure it out myself!")