/[winpt]/trunk/Src/wptGPGMEData.cpp
ViewVC logotype

Diff of /trunk/Src/wptGPGMEData.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 193 by twoaday, Sat Apr 1 12:36:35 2006 UTC revision 200 by twoaday, Mon Apr 17 09:12:50 2006 UTC
# Line 1  Line 1 
1  /* wptGPGMEData.cpp - WinPT specifc data extensions  /* wptGPGMEData.cpp - WinPT specifc data extensions
2   *      Copyright (C) 2001-2005 Timo Schulz   *      Copyright (C) 2001-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 30  Line 30 
30  #include "wptUtil.h"  #include "wptUtil.h"
31  #include "wptGPG.h"  #include "wptGPG.h"
32    
33    
34  /* Implement a word based line break. @inp is the input buffer  /* Implement a word based line break. @inp is the input buffer
35     and @wraplen is the maximal line length.     and @wraplen is the maximal line length.
36     Return value: the wrapped buffer on success. */     Return value: the wrapped buffer on success. */
# Line 143  gpg_data_mail_quote (gpgme_data_t *r_dh) Line 144  gpg_data_mail_quote (gpgme_data_t *r_dh)
144  }  }
145    
146    
147    static int
148    is_armor_header (const char *line)
149    {
150        const char *header[] = {
151            "Version:",
152            "Comment:",
153            "Charset:",
154            "Hash:",
155            "MessageID",
156            NULL
157        };
158        int i;
159    
160        for (i=0; header[i] != NULL; i++) {
161            if (!strncmp (line, header[i], strlen (header[i])))
162                return -1;
163        }
164        return 0;
165    }
166    
167    
168    
169  /* Extract the plaintext data from the escaped data object @sig.  /* Extract the plaintext data from the escaped data object @sig.
170     The plaintxt is stored in @r_plain.     The plaintxt is stored in @r_plain.
171     Return value: 0 on success. */     Return value: 0 on success. */
# Line 162  gpg_data_extract_plaintext (gpgme_data_t Line 185  gpg_data_extract_plaintext (gpgme_data_t
185            
186      while (gpg_data_readline (sig, line, 128) > 0) {      while (gpg_data_readline (sig, line, 128) > 0) {
187          if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) ||          if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) ||
188              !strncmp (line, "Version:", 8) ||              is_armor_header (line))
             !strncmp (line, "Comment:", 8) ||  
             !strncmp (line, "Charset:", 8) ||  
             !strncmp (line, "Hash:", 5) ||  
             !strncmp (line, "MessageID", 9))  
189              continue;              continue;
190          if (strlen (line) <= 2)          if (strlen (line) <= 2)
191              break; /* parsed all headers, now we reached the body */              break; /* parsed all headers, now we reached the body */
192      }      }
193      /* XXX handle multi dash escaped sequences */  
194        /* We just support 1 nesting level. */
195      while (gpg_data_readline (sig, line, 128) > 0 ) {      while (gpg_data_readline (sig, line, 128) > 0 ) {
196          if (!strncmp( line, "-----BEGIN PGP SIGNATURE", 24))          if (!strncmp( line, "-----BEGIN PGP SIGNATURE", 24))
197              break; /* end of plaintext */              break; /* end of plaintext */

Legend:
Removed from v.193  
changed lines
  Added in v.200

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26