Fix a crash saving an attachment with unknown content type.
* src/engine/api/geary-attachment.vala (Attachment): Add a null check for the extension before using it, add a test case to cover it.
This commit is contained in:
parent
5d58f165e6
commit
057e733eb1
2 changed files with 24 additions and 1 deletions
|
|
@ -56,6 +56,8 @@ class Geary.AttachmentTest : TestCase {
|
|||
get_safe_file_name_with_default_content_type);
|
||||
add_test("get_safe_file_name_with_default_content_type_bad_file_name",
|
||||
get_safe_file_name_with_default_content_type_bad_file_name);
|
||||
add_test("get_safe_file_name_with_unknown_content_type",
|
||||
get_safe_file_name_with_unknown_content_type);
|
||||
}
|
||||
|
||||
public override void set_up() {
|
||||
|
|
@ -236,4 +238,25 @@ class Geary.AttachmentTest : TestCase {
|
|||
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
|
||||
}
|
||||
|
||||
public void get_safe_file_name_with_unknown_content_type()
|
||||
throws Error {
|
||||
const string TEST_FILENAME = "test-filename.unlikely";
|
||||
Attachment test = new TestAttachment(
|
||||
ATTACHMENT_ID,
|
||||
this.default_type,
|
||||
CONTENT_ID,
|
||||
CONTENT_DESC,
|
||||
content_disposition,
|
||||
TEST_FILENAME,
|
||||
File.new_for_path(TEST_FILENAME),
|
||||
742
|
||||
);
|
||||
|
||||
test.get_safe_file_name.begin(null, (obj, ret) => {
|
||||
async_complete(ret);
|
||||
});
|
||||
|
||||
assert_string(TEST_FILENAME, test.get_safe_file_name.end(async_result()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue