all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save
@ 2023-06-29 14:14 Dominik Csapak
  2023-06-29 14:14 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Dominik Csapak
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-06-29 14:14 UTC (permalink / raw)
  To: pmg-devel

and warn only when it's an invalid regex on execution, because users may
have previously had such rules. Otherwise, pmg-smtp-filter will restart
every time it encounters such a rule.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PMG/RuleDB/WhoRegex.pm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/PMG/RuleDB/WhoRegex.pm b/src/PMG/RuleDB/WhoRegex.pm
index 5c13604..1db6418 100644
--- a/src/PMG/RuleDB/WhoRegex.pm
+++ b/src/PMG/RuleDB/WhoRegex.pm
@@ -60,6 +60,11 @@ sub save {
     defined($self->{address}) || die "undefined address: ERROR";
 
     my $adr = $self->{address};
+
+    # test regex for validity
+    eval { "" =~ /^$adr$/i; };
+    die "invalid regex: $@\n" if $@;
+
     $adr =~ s/\\/\\\\/g;
     $adr = encode('UTF-8', $adr);
 
@@ -100,7 +105,12 @@ sub who_match {
 
     my $t = $self->address;
 
-    return $addr =~ m/^$t$/i;
+    my $res = '';
+    eval {
+	$res = $addr =~ m/^$t$/i;
+    };
+    warn "invalid regex: $@\n" if $@;
+    return $res;
 }
 
 sub address { 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-11 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAMMJOTSabA-kmpt-UXJFekYxYuK6wu6KAqqRVG2YGF9=obDvyw@mail.gmail.com>
2024-06-11 11:02 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Stoiko Ivanov
2023-06-29 14:14 [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
2023-06-29 14:14 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Dominik Csapak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal