dinhvh / libetpan

Mail Framework for C Language
www.etpan.org
Other
612 stars 284 forks source link

Support obs-FWS in the FWS parser (#431) #435

Open dafanz opened 1 year ago

dafanz commented 1 year ago

The function mailimf_fws_parse() does not support obs-FWS, which is defined in RFC5322, section 3.2.2.

For the example in #431, when msg-id-aaa@example.com is parsed and mailimf_fws_parse() is called after that, it will set cur_token at the position of '\r' in the 5th line. This will cause problems in certain situations. The example in #431 triggers the problem because the message-id afterwards is invalid. Another examples which also trigger problems are that there is a "WSP CRLF" line in the To header field or there are more than three continuous "WSP CRLF" lines in the References header field (see below).

From: AAA <aaa@example.com>
To: BBB <bbb@example.com>,

 CCC <ccc@example.com>
References: <msg-id-aaa@example.com>

 <msg-id-bbb@example.com>
Message-ID: <msg-id-ccc@example.com>

A test mail

The bugfix here adds the support of obs-FWS and fixes all these problems.