Addresses not stored in database in RFC 822 format: Closes #4231

Email addresses were being stored in the database in a human-readable fashion, not proper
quoted RFC 822 format.  This fixes that, as well as another error this exposed in
MessageListCellRenderer dealing with situations where no From: is available.  Courtesy
Charles Lindsay.
This commit is contained in:
Jim Nelson 2011-10-07 17:23:20 -07:00
parent af7c5f585e
commit ee22b632e8
5 changed files with 15 additions and 10 deletions

1
THANKS
View file

@ -1,4 +1,5 @@
The Geary team would like to thank the following contributors:
Eric Gregory <eric@yorba.org>
Charles Lindsay <chaz@chazomatic.us>

View file

@ -15,11 +15,11 @@ public class FormattedMessageData : Object {
public FormattedMessageData(bool is_unread, string date, string from, string subject,
string preview) {
this.is_unread = is_unread;
this.date = "<span foreground='blue'>%s</span>".printf(Geary.String.escape(date));
this.from = "<b>%s</b>".printf(Geary.String.escape(from));
this.subject = "<small>%s</small>".printf(Geary.String.escape(subject));
this.date = "<span foreground='blue'>%s</span>".printf(Geary.String.escape_to_markup(date));
this.from = "<b>%s</b>".printf(Geary.String.escape_to_markup(from));
this.subject = "<small>%s</small>".printf(Geary.String.escape_to_markup(subject));
this.body = "<span size='x-small' foreground='#777777'>%s</span>".printf(
Geary.String.escape(preview));
Geary.String.escape_to_markup(preview));
}
// Creates a formatted message data from an e-mail.
@ -37,9 +37,10 @@ public class FormattedMessageData : Object {
}
}
string from = (email.from.size > 0) ? email.from[0].get_short_address() : "";
this(email.properties.is_unread(), Date.pretty_print(email.date.value),
email.from[0].get_short_address(), email.subject.value,
Geary.String.escape(make_preview(builder.str)));
from, email.subject.value, Geary.String.escape_to_markup(make_preview(builder.str)));
}
// Distills an e-mail body into a preview by removing extra spaces, html, etc.

View file

@ -69,7 +69,10 @@ public class Geary.RFC822.MailboxAddress {
}
public string to_rfc822_string() {
return get_full_address();
return String.is_empty(name)
? "<%s>".printf(address)
: "%s <%s>".printf(GMime.utils_quote_string(name), address)
;
}
public string to_string() {

View file

@ -131,7 +131,7 @@ public class Geary.Sqlite.MessageRow : Geary.Sqlite.Row {
return null;
case 1:
return addrs[0].get_full_address();
return addrs[0].to_rfc822_string();
default:
StringBuilder builder = new StringBuilder();
@ -139,7 +139,7 @@ public class Geary.Sqlite.MessageRow : Geary.Sqlite.Row {
if (!String.is_empty(builder.str))
builder.append(", ");
builder.append(addr.get_full_address());
builder.append(addr.to_rfc822_string());
}
return builder.str;

View file

@ -38,7 +38,7 @@ public inline bool ascii_equali(string a, string b) {
return ascii_cmpi(a, b) == 0;
}
public inline string escape(string? plain) {
public inline string escape_to_markup(string? plain) {
return (!is_empty(plain) && plain.validate()) ? Markup.escape_text(plain) : "";
}