From afd87d50ffa1414a6e6daf9cedb2a8995c661cfc Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Thu, 2 Apr 2020 19:51:45 +0200 Subject: [PATCH] Skip writing default ports in spamreports There is no need to explicitly add ':443' to the authority part of a https URL (or a ':80' to a http one).. Signed-off-by: Stoiko Ivanov Reviewed-By: Dominik Csapak Tested-By: Dominik Csapak --- src/PMG/CLI/pmgqm.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm index 349816a..937269f 100755 --- a/src/PMG/CLI/pmgqm.pm +++ b/src/PMG/CLI/pmgqm.pm @@ -94,7 +94,7 @@ sub get_item_data { $item->{spaminfo} = $ref->{info}; $item->{file} = $ref->{file}; - my $basehref = "$data->{protocol}://$data->{fqdn}:$data->{port}/quarantine"; + my $basehref = "$data->{protocol_fqdn_port}/quarantine"; my $ticket = uri_escape($data->{ticket}); $item->{href} = "$basehref?ticket=$ticket&cselect=$item->{id}&date=$item->{date}"; @@ -248,6 +248,12 @@ __PACKAGE__->register_method ({ my $protocol = $cfg->get('spamquar', 'protocol') // 'https'; + my $protocol_fqdn_port = "$protocol://$fqdn"; + if (($protocol eq 'https' && $port != 443) || + ($protocol eq 'http' && $port != 80)) { + $protocol_fqdn_port .= ":$port"; + } + my $global_data = { protocol => $protocol, port => $port, @@ -256,6 +262,7 @@ __PACKAGE__->register_method ({ date => strftime("%F", localtime($end - 1)), timespan => $timespan, items => [], + protocol_fqdn_port => $protocol_fqdn_port, }; my $mailfrom = $cfg->get ('spamquar', 'mailfrom') // @@ -326,7 +333,7 @@ __PACKAGE__->register_method ({ $data->{pmail} = $creceiver; $data->{ticket} = PMG::Ticket::assemble_quarantine_ticket($data->{pmail}); my $esc_ticket = uri_escape($data->{ticket}); - $data->{managehref} = "$protocol://$fqdn:$port/quarantine?ticket=${esc_ticket}"; + $data->{managehref} = "$protocol_fqdn_port/quarantine?ticket=${esc_ticket}"; } push @{$data->{items}}, get_item_data($data, $ref); -- 2.39.2