From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 84ED3B77D for ; Thu, 24 Nov 2022 13:21:22 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 562842F11F for ; Thu, 24 Nov 2022 13:21:22 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 24 Nov 2022 13:21:21 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DFE5D43CDC for ; Thu, 24 Nov 2022 13:21:14 +0100 (CET) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Thu, 24 Nov 2022 13:21:10 +0100 Message-Id: <20221124122112.666868-11-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221124122112.666868-1-d.csapak@proxmox.com> References: <20221124122112.666868-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [utils.pm] Subject: [pmg-devel] [PATCH pmg-api v4 10/12] utils: refactor rfc1522_to_html X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2022 12:21:22 -0000 by reusing the utf8 decoding logic of decode_rfc1522 Signed-off-by: Dominik Csapak --- src/PMG/Utils.pm | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm index 463de6d..e20fc91 100644 --- a/src/PMG/Utils.pm +++ b/src/PMG/Utils.pm @@ -1135,25 +1135,8 @@ sub decode_rfc1522 { sub rfc1522_to_html { my ($enc) = @_; - my $res = ''; - - return '' if !$enc; - - eval { - foreach my $r (MIME::Words::decode_mimewords($enc)) { - my ($d, $cs) = @$r; - if ($d) { - if ($cs) { - $res .= encode('UTF-8', decode($cs, $d)); - } else { - $res .= $d; - } - } - } - $res = encode_entities(decode('UTF-8', $res)); - }; - - $res = $enc if $@; + my $res = eval { encode_entities(decode_rfc1522($enc)) }; + return $enc if $@; return $res; } -- 2.30.2