Geary.Imap.Deserialiser: Handle reserved chars in response-text

RFC 3501 allows any kind of char except CRLF in `resp-text` after an
optional response code, so handle that.

Addresses another issue in #711
This commit is contained in:
Michael Gratton 2020-05-02 17:13:54 +10:00 committed by Michael James Gratton
parent 16b7d6528d
commit d6d36768f9
2 changed files with 42 additions and 6 deletions

View file

@ -47,6 +47,9 @@ class Geary.Imap.DeserializerTest : TestCase {
// fail, disable for the moment
add_test("invalid_flag_prefix", invalid_flag_prefix);
add_test("reserved_in_response_text", reserved_in_response_text);
add_test("instant_eos", instant_eos);
add_test("bye_eos", bye_eos);
}
@ -220,14 +223,13 @@ class Geary.Imap.DeserializerTest : TestCase {
public void aliyun_greeting() throws Error {
string greeting = "* OK AliYun IMAP Server Ready(10.147.40.164)";
string parsed = "* OK AliYun IMAP Server Ready (10.147.40.164)";
this.stream.add_data(greeting.data);
this.stream.add_data(EOL.data);
this.process.begin(Expect.MESSAGE, this.async_completion);
RootParameters? message = this.process.end(async_result());
assert(message.to_string() == parsed);
assert(message.to_string() == greeting);
}
public void invalid_atom_prefix() throws Error {
@ -320,6 +322,18 @@ class Geary.Imap.DeserializerTest : TestCase {
//this.process.end(async_result());
}
public void reserved_in_response_text() throws Error {
// As seen in #711
string line = """a008 BAD Missing ] in: header.fields""";
this.stream.add_data(line.data);
this.stream.add_data(EOL.data);
this.process.begin(Expect.MESSAGE, this.async_completion);
RootParameters? message = this.process.end(async_result());
assert(message.to_string() == line);
}
public void instant_eos() throws Error {
this.process.begin(Expect.EOS, this.async_completion);
this.process.end(async_result());