Skip to content

Commit cd47c42

Browse files
bengotowclaude
andauthored
Fix incomplete revert of broken IMF quoted string parsing (#28)
Cherry-pick fix from upstream libetpan PR #411. A previous incomplete revert left broken error handling patterns in mailimf_quoted_string_parse and mailimf_fws_quoted_string_parse. The pattern `else if (r == MAILIMF_ERROR_PARSE) break; else { error }` incorrectly breaks out of the parsing loop on parse errors. The correct pattern is `else if (r != MAILIMF_ERROR_PARSE) { error }` which only handles actual errors while allowing MAILIMF_ERROR_PARSE to continue the loop naturally. This restores the original working behavior of IMF field parsing. Upstream: dinhvh/libetpan#411 Related: dinhvh/libetpan#406 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7c9537a commit cd47c42

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Vendor/libetpan/src/low-level/imf/mailimf.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,9 +1441,7 @@ int mailimf_quoted_string_parse(const char * message, size_t length,
14411441
goto free_gstr;
14421442
}
14431443
}
1444-
else if (r == MAILIMF_ERROR_PARSE)
1445-
break;
1446-
else {
1444+
else if (r != MAILIMF_ERROR_PARSE) {
14471445
res = r;
14481446
goto free_gstr;
14491447
}
@@ -1538,15 +1536,13 @@ int mailimf_fws_quoted_string_parse(const char * message, size_t length,
15381536
goto free_gstr;
15391537
}
15401538
}
1541-
else if (r == MAILIMF_ERROR_PARSE)
1542-
break;
1543-
else {
1539+
else if (r != MAILIMF_ERROR_PARSE) {
15441540
res = r;
15451541
goto free_gstr;
15461542
}
1547-
}
1543+
}
15481544

1549-
r = mailimf_dquote_parse(message, length, &cur_token);
1545+
r = mailimf_dquote_parse(message, length, &cur_token);
15501546
if (r != MAILIMF_NO_ERROR) {
15511547
res = r;
15521548
goto free_gstr;

0 commit comments

Comments
 (0)