From 02e4d18398eb72fa40d790770bb7878d0b233d7f Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 23 Feb 2026 10:42:09 +0100 Subject: [PATCH 1/3] Make graphics rendering work again after change to Popen execution mode. Since it does not use a shell anymore, "" were escaped, which prevented JSON output to be loaded properly. --- modoboa/maillog/graphics.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modoboa/maillog/graphics.py b/modoboa/maillog/graphics.py index 4596a692b..9adf09af9 100644 --- a/modoboa/maillog/graphics.py +++ b/modoboa/maillog/graphics.py @@ -41,16 +41,16 @@ class Curve: return [ f"DEF:{self.dsname}={rrdfile}:{self.dsname}:{self.cfunc}", f"CDEF:{self.dsname}pm={self.dsname},UN,0,{self.dsname},IF,60,*", - f'XPORT:{self.dsname}pm:"{self.legend}"', + f"XPORT:{self.dsname}pm:'{self.legend}'", ] class Graphic: """Graphic.""" - def __init__(self): + def __init__(self) -> None: """Constructor.""" - self._curves = [] + self._curves: list[Curve] = [] try: order = self.order except AttributeError: @@ -112,7 +112,7 @@ class Graphic: "--end", str(end), ] + cmdargs - code, output = exec_cmd(cmd) + code, output = exec_cmd(cmd, shell=True) if code: return [] @@ -131,9 +131,9 @@ class Graphic: class GraphicSet: """A set of graphics.""" - domain_selector = False - title = None - _graphics = [] + domain_selector: bool = False + title: str | None = None + _graphics: list[Graphic] = [] def __init__(self, instances=None): if instances is None: From 15a5c1f6803c22c6eb729602d361ad21303768a6 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 23 Feb 2026 12:34:09 +0100 Subject: [PATCH 2/3] Removed shell=True --- modoboa/maillog/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modoboa/maillog/graphics.py b/modoboa/maillog/graphics.py index 9adf09af9..a4b537778 100644 --- a/modoboa/maillog/graphics.py +++ b/modoboa/maillog/graphics.py @@ -112,7 +112,7 @@ class Graphic: "--end", str(end), ] + cmdargs - code, output = exec_cmd(cmd, shell=True) + code, output = exec_cmd(cmd) if code: return [] From a5214b42aee2ab9f18ac0c393a48f6c582cb2964 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 23 Feb 2026 15:28:43 +0100 Subject: [PATCH 3/3] Compatibility fix for chardet 6.x --- modoboa/amavis/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modoboa/amavis/utils.py b/modoboa/amavis/utils.py index d829eb02d..c3a210418 100644 --- a/modoboa/amavis/utils.py +++ b/modoboa/amavis/utils.py @@ -37,7 +37,7 @@ def smart_str(value, *args, **kwargs): return django_smart_str(value, *args, **kwargs) -def fix_utf8_encoding(value): +def fix_utf8_encoding(value: str) -> str: """Fix utf-8 strings that contain utf-8 escaped characters. msgs.from_addr and msgs.subject potentialy contain badly escaped utf-8 @@ -58,12 +58,13 @@ def fix_utf8_encoding(value): value = bytes_value.decode("utf-8") except UnicodeDecodeError: encoding = chardet.detect(bytes_value) - try: - value = bytes_value.decode(encoding["encoding"], "replace") - except (TypeError, UnicodeDecodeError): - # ??? use the original value, we've done our best to try and - # convert it to a clean utf-8 string. - pass + if encoding["confidence"] > 50.0: + try: + value = bytes_value.decode(encoding["encoding"], "replace") + except (TypeError, UnicodeDecodeError): + # ??? use the original value, we've done our best to try and + # convert it to a clean utf-8 string. + pass return value