public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 2/4] ruledb disclaimer: if/elsif code cleanup
Date: Tue,  9 Jan 2024 14:59:02 +0100	[thread overview]
Message-ID: <20240109135906.66200-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240109135906.66200-1-d.csapak@proxmox.com>

by pulling out the text/{html,plain} regex directly in the elsif
condition, since the else there does not do anything

the comment now goes into the top-level else part, but the idea is the
same

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PMG/RuleDB/Disclaimer.pm | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/PMG/RuleDB/Disclaimer.pm b/src/PMG/RuleDB/Disclaimer.pm
index 5eadc6f..24efa8a 100644
--- a/src/PMG/RuleDB/Disclaimer.pm
+++ b/src/PMG/RuleDB/Disclaimer.pm
@@ -165,25 +165,23 @@ sub sign {
 		last;
 	    }
 	}
-    } elsif ($entity->head->mime_type =~ m{text/}) {
-	if ($entity->head->mime_type =~ m{text/(html|plain)}) {
-	    my $type = $1;
-	    my $cs = $entity->head->mime_attr("content-type.charset") // 'ascii';
-	    eval {
-		my $encoded = encode($cs, $type eq 'html' ? $html : $text, Encode::FB_CROAK);
-		$self->add_data($entity, $encoded);
-	    };
-	    # simply ignore if we can't represent the disclainer
-	    # with that encoding
-	    if ($@) {
-		syslog('info', "%s: adding disclaimer failed (rule: %s)", $logid, $rulename);
-	    } else {
-		syslog('info', "%s: added disclaimer (rule: %s)", $logid, $rulename);
-	    }
-	    $found = 1;
+    } elsif ($entity->head->mime_type =~ m{text/(html|plain)}) {
+	my $type = $1;
+	my $cs = $entity->head->mime_attr("content-type.charset") // 'ascii';
+	eval {
+	    my $encoded = encode($cs, $type eq 'html' ? $html : $text, Encode::FB_CROAK);
+	    $self->add_data($entity, $encoded);
+	};
+	# simply ignore if we can't represent the disclainer
+	# with that encoding
+	if ($@) {
+	    syslog('info', "%s: adding disclaimer failed (rule: %s)", $logid, $rulename);
 	} else {
-	    # do nothing - unknown format
+	    syslog('info', "%s: added disclaimer (rule: %s)", $logid, $rulename);
 	}
+	$found = 1;
+    } else {
+	# do nothing - unknown format
     }
 
     return $found;
-- 
2.30.2





  parent reply	other threads:[~2024-01-09 13:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 13:59 [pmg-devel] [PATCH pmg-api/gui] ruledb disclaimer improvements Dominik Csapak
2024-01-09 13:59 ` [pmg-devel] [PATCH pmg-api 1/4] ruledb disclaimer: cleanup trailing whitespace Dominik Csapak
2024-01-12 15:47   ` [pmg-devel] applied: " Thomas Lamprecht
2024-01-09 13:59 ` Dominik Csapak [this message]
2024-01-12 15:47   ` [pmg-devel] applied: [PATCH pmg-api 2/4] ruledb disclaimer: if/elsif code cleanup Thomas Lamprecht
2024-01-09 13:59 ` [pmg-devel] [PATCH pmg-api 3/4] fix #2606: ruledb disclaimer: add ability to add on top Dominik Csapak
2024-01-09 13:59 ` [pmg-devel] [PATCH pmg-api 4/4] fix #2430: ruledb disclaimer: make separator configurable Dominik Csapak
2024-01-09 13:59 ` [pmg-devel] [PATCH pmg-gui 1/2] disclaimer edit: add 'top' checkbox Dominik Csapak
2024-01-12 16:00   ` Thomas Lamprecht
2024-01-09 13:59 ` [pmg-devel] [PATCH pmg-gui 2/2] disclaimer edit: add 'add-separator' checkbox Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240109135906.66200-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal