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 07f5cf0 Allow for relative dates; sanitise stem once
07f5cf0 is described below
commit 07f5cf03a1df31b85779dbc81b1d3218e969b45e
Author: Sebb <[email protected]>
AuthorDate: Sun Sep 19 13:56:53 2021 +0100
Allow for relative dates; sanitise stem once
---
server/endpoints/mbox.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py
index 21a4f1c..815815f 100644
--- a/server/endpoints/mbox.py
+++ b/server/endpoints/mbox.py
@@ -69,7 +69,7 @@ async def process(
lid = indata.get("list", "_")
domain = indata.get("domain", "_")
# may be provided as d= or date=
- yyyymm = indata.get("d") or indata.get("date") # e.g. 2019-9
+ yyyymm = indata.get("d") or indata.get("date") # e.g. 2019-9; can also be
lte=1M etc
try:
query_defuzzed = plugins.defuzzer.defuzz(indata, list_override="@" in
lid and lid or None)
@@ -88,16 +88,15 @@ async def process(
epoch_order="asc"
)
- # 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
+ if len(yyyymm) == 6 and yyyymm[4] == '-': # assume yyyy-m, convert to
yyyy-mm
yyyymm = yyyymm[0:-1] + "0" + yyyymm[-1]
- dlfile = f"{xlist}_{xdomain}_{yyyymm}.mbox"
+ dlstem = f"{lid}_{domain}_{yyyymm}"
else:
- dlfile = f"{xlist}_{xdomain}.mbox"
- headers = {"Content-Type": "application/mbox", "Content-Disposition":
f"attachment; filename={dlfile}"}
+ dlstem = f"{lid}_{domain}"
+ # Figure out a sane filename stem (don't keep '.')
+ dlstem = re.sub(r"[^-_a-z0-9]+", "_", dlstem)
+ headers = {"Content-Type": "application/mbox", "Content-Disposition":
f"attachment; filename={dlstem}.mbox"}
# Return mbox archive with filename as a stream
response = aiohttp.web.StreamResponse(status=200, headers=headers)