Skip to content

Commit

Permalink
Merge pull request #4 from dafanz/master
Browse files Browse the repository at this point in the history
Support obs-FWS in the FWS parser (dinhvh#431)
  • Loading branch information
loomy authored Jun 12, 2023
2 parents 9a2a72d + 05a7808 commit 6adb2a6
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/low-level/imf/mailimf.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ int mailimf_fws_parse(const char * message, size_t length, size_t * indx)
int fws_1;
int fws_2;
int fws_3;
int fws_4;
int r;

cur_token = * indx;
Expand All @@ -847,20 +848,24 @@ int mailimf_fws_parse(const char * message, size_t length, size_t * indx)
}
final_token = cur_token;

r = mailimf_crlf_parse(message, length, &cur_token);
switch (r) {
case MAILIMF_NO_ERROR:
fws_2 = TRUE;
break;
case MAILIMF_ERROR_PARSE:
fws_2 = FALSE;
break;
default:
return r;
}

fws_3 = FALSE;
if (fws_2) {
fws_4 = FALSE;
while (1) {
r = mailimf_crlf_parse(message, length, &cur_token);
switch (r) {
case MAILIMF_NO_ERROR:
fws_2 = TRUE;
break;
case MAILIMF_ERROR_PARSE:
fws_2 = FALSE;
break;
default:
return r;
}
if (!fws_2)
break;

fws_4 = FALSE;
while (1) {
r = mailimf_wsp_parse(message, length, &cur_token);
if (r != MAILIMF_NO_ERROR) {
Expand All @@ -869,14 +874,19 @@ int mailimf_fws_parse(const char * message, size_t length, size_t * indx)
else
return r;
}
final_token = cur_token;
fws_3 = TRUE;
fws_4 = TRUE;
}

if (!fws_4)
break;
}

if ((!fws_1) && (!fws_3))
return MAILIMF_ERROR_PARSE;

if (!fws_3)
if (!fws_4)
cur_token = final_token;

* indx = cur_token;
Expand Down

0 comments on commit 6adb2a6

Please sign in to comment.