This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new e82ca32  Fix up mbox name to be compatible
e82ca32 is described below

commit e82ca3274c2109dec7eeb8600978889ce3c04b5a
Author: Sebb <[email protected]>
AuthorDate: Sun Sep 19 13:15:27 2021 +0100

    Fix up mbox name to be compatible
    
    This fixes #71
---
 server/endpoints/mbox.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py
index 8b60f76..76ad9ae 100644
--- a/server/endpoints/mbox.py
+++ b/server/endpoints/mbox.py
@@ -68,6 +68,7 @@ async def process(
 
     lid = indata.get("list", "_")
     domain = indata.get("domain", "_")
+    yyyymm = indata.get("d") # e.g. 2019-9
 
     try:
         query_defuzzed = plugins.defuzzer.defuzz(indata, list_override="@" in 
lid and lid or None)
@@ -86,10 +87,15 @@ async def process(
         epoch_order="asc"
     )
 
-    # Figure out a sane filename
-    xlist = re.sub(r"[^-_.a-z0-9]+", "_", lid)
-    xdomain = re.sub(r"[^-_.a-z0-9]+", "_", domain)
-    dlfile = f"{xlist}-{xdomain}.mbox"
+    # Figure out a sane filename (don't keep '.')
+    xlist = re.sub(r"[^-_a-z0-9]+", "_", lid)
+    xdomain = re.sub(r"[^-_a-z0-9]+", "_", domain)
+    if yyyymm:
+        if len(yyyymm) == 6: # assume yyyy-m, convert to yyyy-mm
+            yyyymm = yyyymm[0:-1] + "0" + yyyymm[-1]
+        dlfile = f"{xlist}_{xdomain}_{yyyymm}.mbox"
+    else:
+        dlfile = f"{xlist}_{xdomain}.mbox"
     headers = {"Content-Type": "application/mbox", "Content-Disposition": 
f"attachment; filename={dlfile}"}
 
     # Return mbox archive with filename as a stream

Reply via email to