Composer.Widget: Fix criticals when "mailto:" has empty body
This commit is contained in:
parent
13f5602446
commit
bd85c4f1a8
2 changed files with 19 additions and 4 deletions
|
|
@ -575,8 +575,11 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
Gee.HashMultiMap<string, string> headers = new Gee.HashMultiMap<string, string>();
|
||||
if (mailto.has_prefix(MAILTO_URI_PREFIX)) {
|
||||
// Parse the mailto link.
|
||||
string? email = null;
|
||||
string[] parts = mailto.substring(MAILTO_URI_PREFIX.length).split("?", 2);
|
||||
string email = Uri.unescape_string(parts[0]);
|
||||
if (parts.length > 0) {
|
||||
email = Uri.unescape_string(parts[0]);
|
||||
}
|
||||
string[] params = parts.length == 2 ? parts[1].split("&") : new string[0];
|
||||
foreach (string param in params) {
|
||||
string[] param_parts = param.split("=", 2);
|
||||
|
|
@ -587,14 +590,16 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
}
|
||||
|
||||
// Assemble the headers.
|
||||
if (email.length > 0 && headers.contains("to"))
|
||||
if (!Geary.String.is_empty_or_whitespace(email) &&
|
||||
headers.contains("to")) {
|
||||
this.to = "%s,%s".printf(
|
||||
email, Geary.Collection.first(headers.get("to"))
|
||||
);
|
||||
else if (email.length > 0)
|
||||
} else if (!Geary.String.is_empty_or_whitespace(email)) {
|
||||
this.to = email;
|
||||
else if (headers.contains("to"))
|
||||
} else if (headers.contains("to")) {
|
||||
this.to = Geary.Collection.first(headers.get("to"));
|
||||
}
|
||||
|
||||
if (headers.contains("cc"))
|
||||
this.cc = Geary.Collection.first(headers.get("cc"));
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public class Composer.WidgetTest : TestCase {
|
|||
add_test("load_empty_body", load_empty_body);
|
||||
add_test("load_empty_body_to", load_empty_body_to);
|
||||
add_test("load_mailto", load_mailto);
|
||||
add_test("load_mailto_empty", load_mailto_empty);
|
||||
add_test("load_context_edit", load_context_edit);
|
||||
add_test("load_context_reply_sender", load_context_reply_sender);
|
||||
add_test("load_context_reply_sender_with_reply_to", load_context_reply_sender_with_reply_to);
|
||||
|
|
@ -164,6 +165,15 @@ public class Composer.WidgetTest : TestCase {
|
|||
assert_equal(widget.to, "mailto@example.com");
|
||||
}
|
||||
|
||||
public void load_mailto_empty() throws GLib.Error {
|
||||
var widget = new Widget(this.application, this.config, this.account);
|
||||
|
||||
widget.load_mailto.begin("mailto:", this.async_completion);
|
||||
widget.load_mailto.end(async_result());
|
||||
|
||||
assert_equal(widget.to, "");
|
||||
}
|
||||
|
||||
public void load_context_edit() throws GLib.Error {
|
||||
var widget = new Widget(this.application, this.config, this.account);
|
||||
var email = load_email(MESSAGE_WITH_REPLY_TO);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue