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 2021/09/26 23:59:07 UTC

[incubator-ponymail-foal] branch master updated: Don't try to match multiple times

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 7e4f79f  Don't try to match multiple times
7e4f79f is described below

commit 7e4f79f3376e39bfd737db9fbd028dd2eccfa7ae
Author: Sebb <se...@apache.org>
AuthorDate: Mon Sep 27 00:58:37 2021 +0100

    Don't try to match multiple times
---
 server/plugins/defuzzer.py | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/server/plugins/defuzzer.py b/server/plugins/defuzzer.py
index eba321e..8fd1b34 100644
--- a/server/plugins/defuzzer.py
+++ b/server/plugins/defuzzer.py
@@ -58,28 +58,29 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
                 daterange = {"gt": "now-%s" % r}
             elif t == "gte" and r:
                 daterange = {"lt": "now-%s" % r}
-        # simple one month listing
-        m = re.match(r"^(\d\d\d\d-\d+)$", formdata["d"])
-        if m:
-            xdate = m.group(1)
-            dyear, dmonth = xdate.split("-", 1)
-            daterange = {
-                "gte": "%04u-%02u-01||/M" % (int(dyear), int(dmonth)),
-                "lte": "%04u-%02u-01||/M" % (int(dyear), int(dmonth)),
-                "format": "yyyy-MM-dd",
-            }
-
-        # dfr and dto defining a time span
-        m = re.match(r"^dfr=(\d\d\d\d-\d+-\d+)\|dto=(\d\d\d\d-\d+-\d+)$", formdata["d"])
-        if m:
-            dfr = m.group(1)
-            dto = m.group(2)
-            syear, smonth, sday = dfr.split("-", 2)
-            eyear, emonth, eday = dto.split("-", 2)
-            daterange = {
-                "gt": "%04u/%02u/%02u 00:00:00" % (int(syear), int(smonth), int(sday)),
-                "lt": "%04u/%02u/%02u 23:59:59" % (int(eyear), int(emonth), int(eday)),
-            }
+        else:
+            # simple one month listing
+            m = re.match(r"^(\d\d\d\d-\d+)$", formdata["d"])
+            if m:
+                xdate = m.group(1)
+                dyear, dmonth = xdate.split("-", 1)
+                daterange = {
+                    "gte": "%04u-%02u-01||/M" % (int(dyear), int(dmonth)),
+                    "lte": "%04u-%02u-01||/M" % (int(dyear), int(dmonth)),
+                    "format": "yyyy-MM-dd",
+                }
+            else:
+                # dfr and dto defining a time span
+                m = re.match(r"^dfr=(\d\d\d\d-\d+-\d+)\|dto=(\d\d\d\d-\d+-\d+)$", formdata["d"])
+                if m:
+                    dfr = m.group(1)
+                    dto = m.group(2)
+                    syear, smonth, sday = dfr.split("-", 2)
+                    eyear, emonth, eday = dto.split("-", 2)
+                    daterange = {
+                        "gt": "%04u/%02u/%02u 00:00:00" % (int(syear), int(smonth), int(sday)),
+                        "lt": "%04u/%02u/%02u 23:59:59" % (int(eyear), int(emonth), int(eday)),
+                    }
 
     # List parameter(s)
     fqdn = formdata.get("domain", "*")  # If left out entirely, assume wildcard search