]> git.proxmox.com Git - pmg-api.git/commitdiff
ruledb disclaimer: if/elsif code cleanup
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 9 Jan 2024 13:59:02 +0000 (14:59 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 12 Jan 2024 15:46:50 +0000 (16:46 +0100)
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

index 5eadc6fbe07cd9ee54a1489e04df7a10041ca6bc..24efa8a0af768404b6a48227b1efd91aa23727e6 100644 (file)
@@ -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;