From b36accb5e91b991b5dc497a9e54ee9b61cc2715d Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Mon, 10 Jun 2024 10:44:42 +0300 Subject: [PATCH] Add support for embedding calendars https://github.com/webmin/webmin/pull/2193 --- mailbox/view_mail.cgi | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mailbox/view_mail.cgi b/mailbox/view_mail.cgi index 35dd3d61..2b7ed1de 100755 --- a/mailbox/view_mail.cgi +++ b/mailbox/view_mail.cgi @@ -119,6 +119,15 @@ if ($userconfig{'auto_mark'}) { my ($deccode, $decmessage) = &decrypt_attachments($mail); my @attach = @{$mail->{'attach'}}; +# Calendar attachments +my @calendars; +eval { +foreach my $i (grep { $_->{'data'} } + grep { $_->{'type'} =~ /^text\/calendar/ } @attach) { + my $calendars = &parse_calendar_file($i->{'data'}); + push(@calendars, @{$calendars}); + }}; + # Find body attachment and type my ($textbody, $htmlbody, $body) = &find_body($mail, $userconfig{'view_html'}); $body = $htmlbody if ($in{'body'} == 2); @@ -247,10 +256,13 @@ my $image_mode = int(defined($in{'images'}) ? $in{'images'} : $userconfig{'view_images'}); my @bodyright; my $bodycontents; +my $calendars = &get_calendar_data(\@calendars); if ($body && $body->{'data'} =~ /\S/) { if ($body eq $textbody) { # Show plain text $bodycontents = "
";
+		$bodycontents .= $calendars->{'text'}
+			if ($calendars->{'text'});
 		foreach my $l (&wrap_lines(&eucconv($body->{'data'}),
 					$userconfig{'wrap_width'})) {
 			$bodycontents .= &link_urls_and_escape($l,
@@ -264,7 +276,9 @@ if ($body && $body->{'data'} =~ /\S/) {
 		}
 	elsif ($body eq $htmlbody) {
 		# Attempt to show HTML
-		$bodycontents = $body->{'data'};
+		$bodycontents = $calendars->{'html'}
+			if ($calendars->{'html'});
+		$bodycontents .= $body->{'data'};
 		my @imageurls;
 		$bodycontents = &disable_html_images($bodycontents, $image_mode,
 						     \@imageurls);