sprinter_t *format = opt->format;
if (format->is_text_printer) {
- char *mailbox_str;
+ InternetAddress * ia = internet_address_mailbox_new (name, addr);
+ /* mailbox_str has the name part quoted if necessary. Compare
+ * 'John Doe <john@doe.com>' vs. '"Doe, John" <john@doe.com>' */
+ char *mailbox_str = internet_address_to_string (ia, FALSE);
- if (name && *name)
- mailbox_str = talloc_asprintf (format, "%s <%s>", name, addr);
- else
- mailbox_str = talloc_strdup (format, addr);
+ if (! mailbox_str)
+ INTERNAL_ERROR("Out of memory");
- if (! mailbox_str) {
- fprintf (stderr, "Error: out of memory\n");
- return;
- }
if (count > 0) {
format->integer (format, count);
format->string (format, "\t");
format->string (format, mailbox_str);
format->separator (format);
- talloc_free (mailbox_str);
+ g_free (mailbox_str);
} else {
format->begin_map (format);
format->map_key (format, "name");