mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
LibIMAP: Stop parsing immediately on error
This makes the parser more resilient to invalid IMAP messages. Usages of `Optional` have also been removed where the empty case is equivalent to an empty object.
This commit is contained in:
parent
29c477598c
commit
54a28afc13
5 changed files with 333 additions and 314 deletions
|
@ -25,7 +25,9 @@ public:
|
|||
private:
|
||||
static MailboxFlag parse_mailbox_flag(StringView);
|
||||
|
||||
void consume(StringView);
|
||||
ErrorOr<ParseStatus> try_parse(ByteBuffer&& buffer, bool expecting_tag);
|
||||
|
||||
ErrorOr<void> consume(StringView);
|
||||
bool consume_if(StringView);
|
||||
StringView consume_while(Function<bool(u8)> should_consume);
|
||||
StringView consume_until_end_of_line();
|
||||
|
@ -35,39 +37,38 @@ private:
|
|||
ErrorOr<unsigned> parse_number();
|
||||
Optional<unsigned> try_parse_number();
|
||||
|
||||
void parse_response_done();
|
||||
void parse_untagged();
|
||||
void parse_capability_response();
|
||||
ErrorOr<void> parse_response_done();
|
||||
ErrorOr<void> parse_untagged();
|
||||
ErrorOr<void> parse_capability_response();
|
||||
|
||||
StringView parse_atom();
|
||||
StringView parse_quoted_string();
|
||||
StringView parse_literal_string();
|
||||
StringView parse_string();
|
||||
StringView parse_astring();
|
||||
Optional<StringView> parse_nstring();
|
||||
ErrorOr<StringView> parse_quoted_string();
|
||||
ErrorOr<StringView> parse_literal_string();
|
||||
ErrorOr<StringView> parse_string();
|
||||
ErrorOr<StringView> parse_astring();
|
||||
ErrorOr<StringView> parse_nstring();
|
||||
|
||||
ResponseStatus parse_status();
|
||||
ListItem parse_list_item();
|
||||
FetchCommand::DataItem parse_fetch_data_item();
|
||||
FetchResponseData parse_fetch_response();
|
||||
Optional<Vector<Address>> parse_address_list();
|
||||
Address parse_address();
|
||||
HashMap<DeprecatedString, DeprecatedString> parse_body_fields_params();
|
||||
BodyStructure parse_body_structure();
|
||||
BodyStructure parse_one_part_body();
|
||||
BodyExtension parse_body_extension();
|
||||
Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> parse_disposition();
|
||||
Vector<DeprecatedString> parse_langs();
|
||||
Envelope parse_envelope();
|
||||
ErrorOr<ResponseStatus> parse_status();
|
||||
ErrorOr<ListItem> parse_list_item();
|
||||
ErrorOr<FetchCommand::DataItem> parse_fetch_data_item();
|
||||
ErrorOr<FetchResponseData> parse_fetch_response();
|
||||
ErrorOr<Vector<Address>> parse_address_list();
|
||||
ErrorOr<Address> parse_address();
|
||||
ErrorOr<HashMap<DeprecatedString, DeprecatedString>> parse_body_fields_params();
|
||||
ErrorOr<BodyStructure> parse_body_structure();
|
||||
ErrorOr<BodyStructure> parse_one_part_body();
|
||||
ErrorOr<BodyExtension> parse_body_extension();
|
||||
ErrorOr<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> parse_disposition();
|
||||
ErrorOr<Vector<DeprecatedString>> parse_langs();
|
||||
ErrorOr<Envelope> parse_envelope();
|
||||
|
||||
template<typename T>
|
||||
Vector<T> parse_list(T (*converter)(StringView));
|
||||
ErrorOr<Vector<T>> parse_list(T (*converter)(StringView));
|
||||
|
||||
// To retain state if parsing is not finished
|
||||
ByteBuffer m_buffer;
|
||||
SolidResponse m_response;
|
||||
unsigned m_position { 0 };
|
||||
bool m_incomplete { false };
|
||||
bool m_parsing_failed { false };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue