[balsa/wip/gtk4: 129/351] Improve replying to html-only messages



commit 59790d00ee4d492ecdc817356d22779f28c0f4e2
Author: Albrecht Dreß <albrecht dress arcor de>
Date:   Sat Jan 20 17:36:46 2018 -0500

    Improve replying to html-only messages
    
        * configure.ac: check if the selected conversion tool
        accepts “--unicode-snob”.
        * libbalsa/html.c (html2text): run the conversion tool
        with “--unicode-snob” if supported.
    
    Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>

 ChangeLog       |   18 ++++++++++++++++++
 configure.ac    |   10 ++++++++++
 libbalsa/html.c |   13 ++++++++++---
 3 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ca233f6..b20dff4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2018-01-20  Albrecht Dreß <albrecht dress arcor de>
 
+        Improve replying to html-only messages
+
+       * configure.ac: check if the selected conversion tool
+       accepts “--unicode-snob”.
+       * libbalsa/html.c (html2text): run the conversion tool
+       with “--unicode-snob” if supported.
+
+2018-01-20  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Meson build system changes to mirror the autotools changes in
+       the previous commit
+
+       * libnetclient/meson.build: add c_args: '-DG_LOG_DOMAIN="libnetclient"'
+       to static_library arguments.
+       * meson.build: drop sed and ncat prerequisites.
+
+2018-01-20  Albrecht Dreß <albrecht dress arcor de>
+
        Improve low-level network library, POP3 responsiveness on error
 
        * configure.ac: add missing flags and libs for libnetclient unit tests,
diff --git a/configure.ac b/configure.ac
index 782af48..e7e2002 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,6 +316,16 @@ case "$use_html_widget" in
         if test x"$HTML2TEXT" != "xno" ; then
             AC_DEFINE_UNQUOTED(HTML2TEXT, "$HTML2TEXT",
                                [Path to html2text program.])
+                       AC_MSG_CHECKING([whether $HTML2TEXT accepts the --unicode-snob option])
+                       echo "<html/>" > conftest.htm
+                       $HTML2TEXT --unicode-snob conftest.htm > /dev/null 2>&1
+                       if test $? = 0 ; then
+                               AC_MSG_RESULT([yes])
+                               AC_DEFINE(HTML2TEXT_UCOPT,1,[Defined when $HTML2TEXT accepts the 
--unicode-snob option.])
+                       else
+                               AC_MSG_RESULT([no])
+                       fi
+                       rm -f conftest.htm
                else
                        AC_MSG_WARN([You cannot properly quote html-only messags.])
                fi
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 6936b48..9f9afc7 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -84,7 +84,7 @@ lbh_get_body_content(LibBalsaMessageBody * body, gchar ** buf)
 static void
 html2text(gchar ** text, gsize len)
 {
-    gchar *html2text[] = { HTML2TEXT, NULL, NULL };
+    gchar *html2text[] = { HTML2TEXT, NULL, NULL, NULL };
     GFile *html_data;
     GFileIOStream *stream;
     GError *err = NULL;
@@ -98,16 +98,23 @@ html2text(gchar ** text, gsize len)
         if (g_output_stream_write_all(ostream, *text, len,
                                       &bytes_written, NULL, &err)) {
             gchar *result = NULL;
+            gint pathidx;
 
             g_output_stream_flush(ostream, NULL, NULL);
-            html2text[1] = g_file_get_path(html_data);
+#if defined(HTML2TEXT_UCOPT)
+            html2text[1] = "--unicode-snob";
+            pathidx = 2;
+#else
+            pathidx = 1;
+#endif
+            html2text[pathidx] = g_file_get_path(html_data);
             if (g_spawn_sync(NULL, html2text, NULL,
                              G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL,
                              &result, NULL, NULL, &err)) {
                 g_free(*text);
                 *text = result;
             }
-            g_free(html2text[1]);
+            g_free(html2text[pathidx]);
         }
         g_output_stream_close(ostream, NULL, NULL);
         g_object_unref(G_OBJECT(stream));


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