Browse Source

Parse this: =?utf-8?Q?=D0=92=D0=B5=D1=81=D1=82=D0=BD=D0=B8=D0=BA=20=D0=A7=D0=B8=D0=BF=D1=82=D1=80=D0=B8=D0=BF=D0=B0=C2=AE=20:)?= <cheaptripinsider@moitrip.ru>. The colon didn't go through. (https://github.com/MailCore/mailcore2/issues/870)

pull/2/merge
Hoa V. DINH 8 years ago
parent
commit
7020007cfc
3 changed files with 63 additions and 11 deletions
  1. +52
    -1
      src/low-level/imf/mailimf.c
  2. +5
    -10
      src/low-level/mime/mailmime_decode.c
  3. +6
    -0
      src/low-level/mime/mailmime_decode.h

+ 52
- 1
src/low-level/imf/mailimf.c View File

@ -55,6 +55,7 @@
#include "mmapstring.h"
#include <stdlib.h>
#include <string.h>
#include "mailmime_decode.h"
#ifndef TRUE
#define TRUE 1
@ -1216,6 +1217,56 @@ int mailimf_atom_parse(const char * message, size_t length,
return res;
}
int mailimf_fws_atom_for_word_parse(const char * message, size_t length,
size_t * indx, char ** result)
{
size_t end;
size_t cur_token;
int r;
int res;
struct mailmime_encoded_word * word;
int has_fwd;
char * atom;
cur_token = * indx;
r = mailimf_fws_parse(message, length, &cur_token);
if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
res = r;
goto err;
}
end = cur_token;
r = mailmime_encoded_word_parse(message, length, &cur_token, &word, &has_fwd);
if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
res = r;
goto err;
}
if (r == MAILIMF_ERROR_PARSE) {
return mailimf_fws_atom_parse(message, length, indx, result);
}
mailmime_encoded_word_free(word);
atom = malloc(cur_token - end + 1);
if (atom == NULL) {
res = MAILIMF_ERROR_MEMORY;
goto err;
}
strncpy(atom, message + end, cur_token - end);
atom[cur_token - end] = '\0';
* result = atom;
* indx = cur_token;
return MAILIMF_NO_ERROR;
err:
return res;
}
int mailimf_fws_atom_parse(const char * message, size_t length,
size_t * indx, char ** result)
{
@ -1590,7 +1641,7 @@ int mailimf_fws_word_parse(const char * message, size_t length,
cur_token = * indx;
r = mailimf_fws_atom_parse(message, length, &cur_token, &word);
r = mailimf_fws_atom_for_word_parse(message, length, &cur_token, &word);
if (r == MAILIMF_ERROR_PARSE)
r = mailimf_fws_quoted_string_parse(message, length, &cur_token, &word);


+ 5
- 10
src/low-level/mime/mailmime_decode.c View File

@ -87,12 +87,7 @@ mailmime_non_encoded_word_parse(const char * message, size_t length,
size_t * indx,
char ** result, int * p_has_fwd);
static int
mailmime_encoded_word_parse(const char * message, size_t length,
size_t * indx,
struct mailmime_encoded_word ** result,
int * p_has_fwd);
enum {
TYPE_ERROR,
@ -368,10 +363,10 @@ mailmime_non_encoded_word_parse(const char * message, size_t length,
return res;
}
static int mailmime_encoded_word_parse(const char * message, size_t length,
size_t * indx,
struct mailmime_encoded_word ** result,
int * p_has_fwd)
int mailmime_encoded_word_parse(const char * message, size_t length,
size_t * indx,
struct mailmime_encoded_word ** result,
int * p_has_fwd)
{
size_t cur_token;
char * charset;


+ 6
- 0
src/low-level/mime/mailmime_decode.h View File

@ -49,6 +49,12 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
size_t * indx, const char * tocode,
char ** result);
int
mailmime_encoded_word_parse(const char * message, size_t length,
size_t * indx,
struct mailmime_encoded_word ** result,
int * p_has_fwd);
#ifdef __cplusplus
}
#endif


Loading…
Cancel
Save