skip whitespace while testing for PGP message
authorVolker Birk <vb@pep-project.org>
Mon, 01 Jun 2015 22:25:40 +0200
changeset 308e3e4305cfa34
parent 307 e961e773c32e
child 309 41158bfd751d
skip whitespace while testing for PGP message
src/mime.c
test/msg.asc
     1.1 --- a/src/mime.c	Mon Jun 01 01:08:25 2015 +0200
     1.2 +++ b/src/mime.c	Mon Jun 01 22:25:40 2015 +0200
     1.3 @@ -9,11 +9,27 @@
     1.4  #include "etpan_mime.h"
     1.5  #include "wrappers.h"
     1.6  
     1.7 +static bool iswhitespace(char c)
     1.8 +{
     1.9 +    switch (c) {
    1.10 +        case ' ':
    1.11 +        case '\t':
    1.12 +        case '\r':
    1.13 +        case '\n':
    1.14 +            return true;
    1.15 +
    1.16 +        default:
    1.17 +            return false;
    1.18 +    }
    1.19 +}
    1.20 +
    1.21  DYNAMIC_API bool is_PGP_message_text(const char *text)
    1.22  {
    1.23      if (text == NULL)
    1.24          return false;
    1.25  
    1.26 +    for (; *text && iswhitespace(*text); text++);
    1.27 +
    1.28      return strncmp(text, "-----BEGIN PGP MESSAGE-----", 27) == 0;
    1.29  }
    1.30  
     2.1 --- a/test/msg.asc	Mon Jun 01 01:08:25 2015 +0200
     2.2 +++ b/test/msg.asc	Mon Jun 01 22:25:40 2015 +0200
     2.3 @@ -1,3 +1,4 @@
     2.4 +
     2.5  -----BEGIN PGP MESSAGE-----
     2.6  Version: GnuPG v1
     2.7  Comment: GPGTools - http://gpgtools.org