]> git.proxmox.com Git - pmg-api.git/commitdiff
html mail: dump: fix indentation and clean up a bit
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 25 Nov 2021 17:17:10 +0000 (18:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 26 Nov 2021 08:56:13 +0000 (09:56 +0100)
move in the variable declaration, keep $depth even if it's unused
currently, at least its set correctly now..

drop the `.. unless expr` usage, against the style guide

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/HTMLMail.pm

index 2b85909a5a0d27e5f4fe431c74aebde10cd29dfe..9135f3b203a8e8d28721b21d2b6ec655f4ee2f2d 100644 (file)
@@ -40,49 +40,42 @@ sub dump_html {
 
     my @html = ();
 
-    my($tag, $node, $start, $depth);
-
-    $tree->traverse(
-       sub {
-           ($node, $start) = @_;
-           if(ref $node) {
-               $tag = $node->{'_tag'};
-
-               # try to open a new window when user activates a anchor
-               $node->{target} = '_blank' if $tag eq 'a';
-
-               if ($tag eq 'img' && $view_images) {
-                   if ($node->{src} && $node->{src} =~ m/^cid:(\S+)$/) {
-                       if (my $datauri = $cid_hash->{$1}) {
-                           $node->{src} = $datauri;
-                       }
+    $tree->traverse(sub {
+       my ($node, $start, $depth) = @_;
+       if (ref $node) {
+           my $tag = $node->{'_tag'};
+
+           # try to open a new window when user activates a anchor
+           $node->{target} = '_blank' if $tag eq 'a';
+
+           if ($tag eq 'img' && $view_images) {
+               if ($node->{src} && $node->{src} =~ m/^cid:(\S+)$/) {
+                   if (my $datauri = $cid_hash->{$1}) {
+                       $node->{src} = $datauri;
                    }
                }
+           }
 
-               if ($tag eq 'style' && !$view_images) {
-                   remove_urls($_) for grep { !ref $$_ } $node->content_refs_list();
-               }
+           if ($tag eq 'style' && !$view_images) {
+               remove_urls($_) for grep { !ref $$_ } $node->content_refs_list();
+           }
 
-               if($start) { # on the way in
-                   push(@html, $node->starttag);
-               } else {
-                   # on the way out
-                   push(@html, $node->endtag);
-               }
-           } else {
-               # simple text content
-               $node = encode_entities($node)
-                   # That does magic things if $entities is undef.
-                   unless $HTML::Tagset::isCDATA_Parent{ $_[3]{'_tag'} };
-               # To keep from amp-escaping children of script et al.
-               # That doesn't deal with descendants; but then, CDATA
-               #  parents shouldn't /have/ descendants other than a
-               #  text children (or comments?)
-               push(@html, $node);
+           if ($start) { # on the way in
+               push(@html, $node->starttag);
+           } else { # on the way out
+               push(@html, $node->endtag);
+           }
+       } else { # simple text content
+           # To keep from amp-escaping children of script et al. That doesn't deal with descendants;
+           # but then, CDATA parents shouldn't /have/ descendants other than a text children (or comments?)
+           if (!$HTML::Tagset::isCDATA_Parent{ $_[3]{'_tag'} }) {
+               # That does magic things if $entities is undef.
+               $node = encode_entities($node);
            }
-           1; # keep traversing
+           push(@html, $node);
        }
-    );
+       return 1; # keep traversing
+    });
 
     return join('', @html, "\n");
 }