[balsa/gmime3: 4/49] internet_address_list_parse_string() replaced



commit 781b9ea84b9bced9ee76d99c73569be49b579a4e
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Nov 20 18:47:46 2019 -0800

    internet_address_list_parse_string() replaced
    
    by internet_address_list_parse(), with a parser-options argument.
    
    -    InternetAddressList *list = internet_address_list_parse_string(string);
    +    InternetAddressList *list = internet_address_list_parse(libbalsa_parser_options(), string);
    +

 libbalsa/address-view.c           |  5 +++--
 libbalsa/message.c                | 12 ++++++------
 libbalsa/misc.c                   | 16 ++++++++++++++++
 libbalsa/misc.h                   |  4 ++++
 src/balsa-mime-widget-message.c   |  2 +-
 src/balsa-mime-widget-vcalendar.c |  2 +-
 src/sendmsg-window.c              |  4 ++--
 7 files changed, 33 insertions(+), 12 deletions(-)
---
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 294833cd2..86bae0c8c 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -419,7 +419,8 @@ static gboolean
 lbav_add_from_string(LibBalsaAddressView * address_view,
                      GtkTreeIter * iter, const gchar * string)
 {
-    InternetAddressList *list = internet_address_list_parse_string(string);
+    InternetAddressList *list = internet_address_list_parse(libbalsa_parser_options(), string);
+
     gboolean retval = FALSE;
 
     if (list) {
@@ -1255,7 +1256,7 @@ libbalsa_address_view_get_list(LibBalsaAddressView * address_view,
 
         if (this_type == type) {
             InternetAddressList *tmp_list =
-                internet_address_list_parse_string(name);
+                internet_address_list_parse(libbalsa_parser_options(), name);
             if (tmp_list) {
                 internet_address_list_append(address_list, tmp_list);
                 g_object_unref(tmp_list);
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 8f4251c70..5aa0e442f 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -991,7 +991,7 @@ lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
     g_return_if_fail(mime_msg != NULL);
 
     if (headers->from == NULL)
-        headers->from = internet_address_list_parse_string(mime_msg->from);
+        headers->from = internet_address_list_parse(libbalsa_parser_options(), mime_msg->from);
 
     if (headers->date == 0)
         g_mime_message_get_date(mime_msg, &headers->date, NULL);
@@ -1029,12 +1029,12 @@ lb_message_headers_extra_from_gmime(LibBalsaMessageHeaders *headers,
 
     if (headers->reply_to == NULL) {
         headers->reply_to =
-            internet_address_list_parse_string(mime_msg->reply_to);
+            internet_address_list_parse(libbalsa_parser_options(), mime_msg->reply_to);
     }
 
     if (headers->dispnotify_to == NULL) {
         headers->dispnotify_to =
-            internet_address_list_parse_string(g_mime_object_get_header
+            internet_address_list_parse(libbalsa_parser_options(), g_mime_object_get_header
                                                    (GMIME_OBJECT(mime_msg),
                                                    "Disposition-Notification-To"));
     }
@@ -1235,10 +1235,10 @@ lbmsg_set_header(LibBalsaMessage *message,
         message->headers->date = g_mime_utils_header_decode_date(value, NULL);
     } else if ((message->headers->from == NULL) &&
                (g_ascii_strcasecmp(name, "From") == 0)) {
-        message->headers->from = internet_address_list_parse_string(value);
+        message->headers->from = internet_address_list_parse(libbalsa_parser_options(), value);
     } else if ((message->headers->to_list == NULL) &&
                (g_ascii_strcasecmp(name, "To") == 0)) {
-        message->headers->to_list = internet_address_list_parse_string(value);
+        message->headers->to_list = internet_address_list_parse(libbalsa_parser_options(), value);
     } else if (g_ascii_strcasecmp(name, "In-Reply-To") == 0) {
         libbalsa_message_set_in_reply_to_from_string(message, value);
     } else if ((message->message_id == NULL) &&
@@ -1251,7 +1251,7 @@ lbmsg_set_header(LibBalsaMessage *message,
         message->headers->content_type = g_mime_content_type_new_from_string(value);
     } else if ((message->headers->dispnotify_to == NULL) &&
                (g_ascii_strcasecmp(name, "Disposition-Notification-To") == 0)) {
-        message->headers->dispnotify_to = internet_address_list_parse_string(value);
+        message->headers->dispnotify_to = internet_address_list_parse(libbalsa_parser_options(), value);
     } else
 #ifdef MESSAGE_COPY_CONTENT
     if (g_ascii_strcasecmp(name, "Content-Length") == 0) {
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index e93324050..99fb3da5d 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -1211,3 +1211,19 @@ libbalsa_font_string_to_css(const gchar * font_string,
     return g_string_free(string, FALSE);
 #endif                          /* !GTK_CHECK_VERSION(3, 22,0) */
 }
+
+static GMimeParserOptions *parser_options;
+
+void
+libbalsa_parser_options_init(void)
+{
+    parser_options = g_mime_parser_options_new();
+    g_mime_parser_options_set_rfc2047_compliance_mode(parser_options,
+                                                      GMIME_RFC_COMPLIANCE_LOOSE);
+}
+
+GMimeParserOptions *
+libbalsa_parser_options(void)
+{
+    return parser_options;
+}
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index b2639e6d1..c9d36b5fe 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -158,4 +158,8 @@ gchar * libbalsa_text_to_html(const gchar * title, const gchar * body, const gch
 GString * libbalsa_html_encode_hyperlinks(GString * paragraph);
 gchar *libbalsa_font_string_to_css(const gchar * font_string, const gchar * name);
 
+void libbalsa_parser_options_init(void);
+GMimeParserOptions *libbalsa_parser_options(void);
+
+
 #endif                         /* __LIBBALSA_MISC_H__ */
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 6d1e7e0e7..9e79549a3 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -360,7 +360,7 @@ extbody_send_mail(GtkWidget * button, LibBalsaMessageBody * mime_body)
     }
 
     data = libbalsa_message_body_get_parameter(mime_body, "server");
-    headers->to_list = internet_address_list_parse_string(data);
+    headers->to_list = internet_address_list_parse(libbalsa_parser_options(), data);
     g_free(data);
 
     /* the original body my have some data to be returned as commands... */
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index 94cfa0bf9..abf5ab466 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -306,7 +306,7 @@ vevent_reply(GObject * button, GtkWidget * box)
     headers = libbalsa_message_get_headers(message);
     headers->from = internet_address_list_new();
     internet_address_list_add(headers->from, ia);
-    headers->to_list = internet_address_list_parse_string(rcpt);
+    headers->to_list = internet_address_list_parse(libbalsa_parser_options(), rcpt);
     headers->date = time(NULL);
 
     /* create the message subject */
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index fcf6053db..6f4c8b241 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1096,7 +1096,7 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
         bcc_list =
             libbalsa_address_view_get_list(bsmsg->recipient_view, "BCC:");
 
-        ident_list = internet_address_list_parse_string(addr);
+        ident_list = internet_address_list_parse(libbalsa_parser_options(), addr);
         if (ident_list) {
             /* Remove any Bcc addresses that came from the old identity
              * from the list. */
@@ -1126,7 +1126,7 @@ update_bsmsg_identity(BalsaSendmsg* bsmsg, LibBalsaIdentity* ident)
 
         /* Add the new Bcc addresses, if any: */
         addr = libbalsa_identity_get_bcc(ident);
-        ident_list = internet_address_list_parse_string(addr);
+        ident_list = internet_address_list_parse(libbalsa_parser_options(), addr);
         if (ident_list) {
             internet_address_list_append(bcc_list, ident_list);
             g_object_unref(ident_list);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]