[PATCH] fix PGP detection

Locked
mirabilos
Znuny newbie
Posts: 7
Joined: 26 Aug 2011, 11:03
Znuny Version: 2.2.7
Real Name: Thorsten Glaser
Company: tarent solutions GmbH

[PATCH] fix PGP detection

Post by mirabilos »

Code: Select all

--- /usr/share/otrs/Kernel/Output/HTML/ArticleCheckPGP.pm.orig	2007-08-22 13:00:08.000000000 +0200
+++ /usr/share/otrs/Kernel/Output/HTML/ArticleCheckPGP.pm	2011-09-08 11:13:41.000000000 +0200
@@ -54,7 +54,7 @@ sub Check {
         return;
     }
     # check inline pgp crypt
-    if ($Param{Article}->{Body} =~ /^-----BEGIN PGP MESSAGE-----/) {
+    if ($Param{Article}->{Body} =~ /^\s*-----BEGIN PGP MESSAGE-----/) {
         # check sender (don't decrypt sent emails)
         if ($Param{Article}->{SenderType} =~ /(agent|system)/i) {
             # return info
@@ -87,7 +87,7 @@ sub Check {
         }
     }
     # check inline pgp signature
-    if ($Param{Article}->{Body} =~ /^-----BEGIN PGP SIGNED MESSAGE-----/) {
+    if ($Param{Article}->{Body} =~ /^\s*-----BEGIN PGP SIGNED MESSAGE-----/) {
         %SignCheck = $Self->{CryptObject}->Verify(
             Message => $Param{Article}->{Body},
         );
@@ -228,7 +228,7 @@ sub Filter {
     # remove signature if one is found
     if ($Self->{Result}->{SignatureFound}) {
         # remove pgp begin signed message
-        $Param{Article}->{Body} =~ s/^-----BEGIN\sPGP\sSIGNED\sMESSAGE-----.+?Hash:\s.+?$//sm;
+        $Param{Article}->{Body} =~ s/^\s*-----BEGIN\sPGP\sSIGNED\sMESSAGE-----.+?Hash:\s.+?$//sm;
         # remove pgp inline sign
         $Param{Article}->{Body} =~ s/^-----BEGIN\sPGP\sSIGNATURE-----.+?-----END\sPGP\sSIGNATURE-----//sm;
     }

Enigmail on Thunderbird for Windows® may precede the -----BEGIN……… with a blank line, failing automatic decryption.
This patch is against otrs2_2.2.7-2lenny3.
Locked