Hi all,

I just commited some changes so that GPG does not try to decrypt/verify
a message with a public key block, but the commit aborted before sending
the mail.

So here is the patch:


cvs -z3 diff -u -wb src\modules\viewflt\PGP.cpp (in directory U:\src\M\)
Index: src/modules/viewflt/PGP.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/viewflt/PGP.cpp,v
retrieving revision 1.15
diff -u -w -b -r1.15 PGP.cpp
--- src/modules/viewflt/PGP.cpp        17 Jun 2003 08:22:20 -0000        1.15
+++ src/modules/viewflt/PGP.cpp        9 Jul 2003 13:14:26 -0000
@@ -168,16 +168,25 @@
    {
       // is the message just signed or encrypted?
       const char *tail = start + strlen(PGP_BEGIN_PREFIX);
+      bool isKey = false;
       bool isSigned = strncmp(tail, "SIGNED ", 7 /* strlen("SIGNED ") */) == 0;
       if ( isSigned )
       {
          tail += 7;
       }
+      else
+      {
+         isKey = strncmp(tail, "PUBLIC KEY ", 11 /* strlen("PUBLIC KEY ") */) == 0;
+      }
 
       // this flag tells us if everything is ok so far -- as soon as it becomes
       // false, we skip all subsequent steps
-      bool ok = true;
-      if ( strncmp(tail, PGP_BEGIN_SUFFIX, strlen(PGP_BEGIN_SUFFIX)) != 0 )
+      // We do not know (yet) what to do with public key blocks, so let's consider
+      // that they're not ok.
+      // TODO: propose to import it into the keyring?
+      bool ok = !isKey;
+
+      if ( ok && strncmp(tail, PGP_BEGIN_SUFFIX, strlen(PGP_BEGIN_SUFFIX)) != 0 )
       {
          wxLogWarning(_("The BEGIN line doesn't end with expected suffix."));
 
@@ -328,9 +337,12 @@
          return;
       }
 
-      // give a warning and display the message normally
+      // give a warning (unless this is a KEY blok and display the message normally
+      if ( !isKey )
+      {
       wxLogWarning(_("This message seems to be PGP signed or encrypted "
                      "but in fact is not."));
+      }
    }
 
    m_next->Process(text, viewer, style);


-- 
Xavier Nodet
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." - Benjamin Franklin, 1759.


Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to