[Commits] [SCM] claws branch, master, updated. 3.17.2-3-g74e46ec

ticho at claws-mail.org ticho at claws-mail.org
Fri Dec 14 18:54:51 CET 2018


The branch, master has been updated
       via  74e46ecdb43be8fb8d79683426eed3b917f0430d (commit)
       via  476d7eca501ac7a5b367567297e028e89cc7e716 (commit)
      from  8f5e5040eb3e4599078090303562dbe4d5416e03 (commit)

Summary of changes:
 src/common/tests/Makefile.am               |    4 +
 src/common/tests/utils_get_uri_part_test.c |  125 ++++++++++++++++++++++++++++
 src/common/utils.c                         |    7 +-
 3 files changed, 133 insertions(+), 3 deletions(-)
 create mode 100644 src/common/tests/utils_get_uri_part_test.c


- Log -----------------------------------------------------------------
commit 74e46ecdb43be8fb8d79683426eed3b917f0430d
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Dec 14 18:51:40 2018 +0100

    Added unit tests for get_uri_part().

diff --git a/src/common/tests/Makefile.am b/src/common/tests/Makefile.am
index b03e287..767f6de 100644
--- a/src/common/tests/Makefile.am
+++ b/src/common/tests/Makefile.am
@@ -30,6 +30,10 @@ TEST_PROGS += unmime_test
 unmime_test_SOURCES = unmime_test.c
 unmime_test_LDADD = $(common_ldadd) ../unmime.o ../quoted-printable.o ../utils.o ../file-utils.o ../codeconv.o
 
+TEST_PROGS += utils_get_uri_part_test
+utils_get_uri_part_test_SOURCES = utils_get_uri_part_test.c
+utils_get_uri_part_test_LDADD = $(common_ldadd) ../utils.o ../file-utils.o ../codeconv.o ../quoted-printable.o ../unmime.o
+
 noinst_PROGRAMS = $(TEST_PROGS)
 
 .PHONY: test
diff --git a/src/common/tests/utils_get_uri_part_test.c b/src/common/tests/utils_get_uri_part_test.c
new file mode 100644
index 0000000..18ab31c
--- /dev/null
+++ b/src/common/tests/utils_get_uri_part_test.c
@@ -0,0 +1,125 @@
+#include <stdio.h>
+#include <glib.h>
+
+#include "utils.h"
+
+#include "mock_prefs_common_get_use_shred.h"
+#include "mock_prefs_common_get_flush_metadata.h"
+
+struct td_get_uri_part {
+	gchar *str;
+	gboolean ret;
+	guint uri_length;
+};
+
+struct td_get_uri_part td_get_uri_basic = {
+	"http://www.example.com", TRUE, 22
+};
+struct td_get_uri_part td_get_uri_slash = {
+	"http://www.example.com/", TRUE, 23
+};
+struct td_get_uri_part td_get_uri_question = {
+	"http://www.example.com/foo?", TRUE, 27
+};
+struct td_get_uri_part td_get_uri_parenthesis = {
+	"http://www.example.com/f(o)o", TRUE, 28
+};
+struct td_get_uri_part td_get_uri_brace = {
+	"http://www.example.com/f[oo", TRUE, 24
+};
+struct td_get_uri_part td_get_uri_umlaut = {
+	"http://www.examöple.com", TRUE, 24
+};
+struct td_get_uri_part td_get_uri_kanji = {
+	"http://www.漢字.com", TRUE, 21
+};
+struct td_get_uri_part td_get_uri_nonprintable = {
+	"http://www.exam\x01ple.com", TRUE, 15
+};
+
+#define URI "http://www.example.com"
+static void
+test_utils_get_uri_part_nowhitespace()
+{
+	gboolean ret;
+	gchar *str = g_strdup("Nowhitespace"URI"nowhitespace");
+	const gchar *bp, *ep;
+
+	ret = get_uri_part(str, str + 12, &bp, &ep, FALSE);
+
+	g_assert_true(ret);
+	g_assert_true(ep == str + strlen(str));
+
+	g_free(str);
+}
+
+static void
+test_utils_get_uri_part_whitespace()
+{
+	gboolean ret;
+	gchar *str = g_strdup("Whitespace "URI" whitespace");
+	const gchar *bp, *ep;
+
+	ret = get_uri_part(str, str + 11, &bp, &ep, FALSE);
+
+	g_assert_true(ret);
+	g_assert_true(ep == bp + strlen(URI));
+
+	g_free(str);
+}
+#undef URI
+
+static void
+test_utils_get_uri_part(gconstpointer user_data)
+{
+	const struct td_get_uri_part *data = (struct td_get_uri_part *)user_data;
+	gboolean ret;
+	const gchar *bp, *ep;
+
+	ret = get_uri_part(data->str, data->str, &bp, &ep, FALSE);
+
+	g_assert_nonnull(bp);
+	g_assert_nonnull(ep);
+
+	g_assert_true(ret == data->ret);
+	g_assert_true(ep >= bp);
+	g_assert_true(bp + data->uri_length == ep);
+}
+
+int
+main(int argc, char *argv[])
+{
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/common/utils/get_uri_part/nowhitespace",
+			test_utils_get_uri_part_nowhitespace);
+	g_test_add_func("/common/utils/get_uri_part/whitespace",
+			test_utils_get_uri_part_whitespace);
+
+	g_test_add_data_func("/common/utils/get_uri_part/basic",
+			&td_get_uri_basic,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/slash",
+			&td_get_uri_slash,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/question",
+			&td_get_uri_question,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/parenthesis",
+			&td_get_uri_parenthesis,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/brace",
+			&td_get_uri_brace,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/umlaut",
+			&td_get_uri_umlaut,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/kanji",
+			&td_get_uri_kanji,
+			test_utils_get_uri_part);
+	g_test_add_data_func("/common/utils/get_uri_part/nonprintable",
+			&td_get_uri_nonprintable,
+			test_utils_get_uri_part);
+
+	return g_test_run();
+}

commit 476d7eca501ac7a5b367567297e028e89cc7e716
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Dec 14 18:50:38 2018 +0100

    Make URI highlighting in textview and compose Unicode-aware.
    
    Fixes bug #3519: Links including umlauts are broken

diff --git a/src/common/utils.c b/src/common/utils.c
index f288888..5774c4d 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -3404,9 +3404,10 @@ gboolean get_uri_part(const gchar *start, const gchar *scanpos,
 	*bp = scanpos;
 
 	/* find end point of URI */
-	for (ep_ = scanpos; *ep_ != '\0'; ep_++) {
-		if (!g_ascii_isgraph(*(const guchar *)ep_) ||
-		    !IS_ASCII(*(const guchar *)ep_) ||
+	for (ep_ = scanpos; *ep_ != '\0'; ep_ = g_utf8_next_char(ep_)) {
+		gunichar u = g_utf8_get_char_validated(ep_, -1);
+		if (!g_unichar_isgraph(u) ||
+		    u == (gunichar)-1 ||
 		    strchr("[]{}<>\"", *ep_)) {
 			break;
 		} else if (strchr("(", *ep_)) {

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list