[Commits] [SCM] claws branch, master, updated. 3.18.0-284-g0578ee723
mones at claws-mail.org
mones at claws-mail.org
Sat Nov 6 14:06:10 UTC 2021
The branch, master has been updated
via 0578ee72394db30e451d7eaf638cc5cbdbfa3fd9 (commit)
from 4b26e5875785e87b994d5d81f6f15582726abd5f (commit)
Summary of changes:
src/common/utils.c | 15 +++++++++++++++
src/common/utils.h | 1 +
src/mainwindow.c | 8 ++------
src/plugins/vcalendar/vcal_folder.c | 11 +----------
4 files changed, 19 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit 0578ee72394db30e451d7eaf638cc5cbdbfa3fd9
Author: Ricardo Mones <ricardo at mones.org>
Date: Sat Nov 6 15:04:58 2021 +0100
Refactor CRLF-truncation into a function
diff --git a/src/common/utils.c b/src/common/utils.c
index 47c56cbb7..4dc6339a3 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -284,6 +284,21 @@ gchar *strcrchomp(gchar *str)
return str;
}
+/* truncates string at first CR (carriage return) or LF (line feed) */
+gchar *strcrlftrunc(gchar *str)
+{
+ gchar *p = NULL;
+
+ if ((str == NULL) || (!*str)) return str;
+
+ if ((p = strstr(str, "\r")) != NULL)
+ *p = '\0';
+ if ((p = strstr(str, "\n")) != NULL)
+ *p = '\0';
+
+ return str;
+}
+
#ifndef HAVE_STRCASESTR
/* Similar to `strstr' but this function ignores the case of both strings. */
gchar *strcasestr(const gchar *haystack, const gchar *needle)
diff --git a/src/common/utils.h b/src/common/utils.h
index 98f771291..787e48f23 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -273,6 +273,7 @@ gchar *strretchomp (gchar *str);
gchar *strtailchomp (gchar *str,
gchar tail_char);
gchar *strcrchomp (gchar *str);
+gchar *strcrlftrunc (gchar *str);
#ifndef HAVE_STRCASESTR
gchar *strcasestr (const gchar *haystack,
const gchar *needle);
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 2b3511f00..b44cb90db 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -5480,7 +5480,6 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
void mainwindow_jump_to(const gchar *target, gboolean popup)
{
gchar *tmp = NULL;
- gchar *p = NULL;
FolderItem *item = NULL;
gchar *msg = NULL;
MainWindow *mainwin = mainwindow_get_mainwindow();
@@ -5497,11 +5496,8 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
tmp = from_uri;
else
tmp = g_strdup(target);
-
- if ((p = strstr(tmp, "\r")) != NULL)
- *p = '\0';
- if ((p = strstr(tmp, "\n")) != NULL)
- *p = '\0';
+
+ strcrlftrunc(tmp);
if ((item = folder_find_item_from_identifier(tmp))) {
g_print("selecting folder '%s'\n", tmp);
diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c
index d80951adf..6a39e35de 100644
--- a/src/plugins/vcalendar/vcal_folder.c
+++ b/src/plugins/vcalendar/vcal_folder.c
@@ -1789,19 +1789,10 @@ static gchar *feed_get_title(const gchar *str)
gchar *title = NULL;
if (strstr(str, "X-WR-CALNAME:")) {
title = g_strdup(strstr(str, "X-WR-CALNAME:")+strlen("X-WR-CALNAME:"));
- if (strstr(title, "\n"))
- *(strstr(title, "\n")) = '\0';
- if (strstr(title, "\r"))
- *(strstr(title, "\r")) = '\0';
} else if (strstr(str, "X-WR-CALDESC:")) {
title = g_strdup(strstr(str, "X-WR-CALDESC:")+strlen("X-WR-CALDESC:"));
- if (strstr(title, "\n"))
- *(strstr(title, "\n")) = '\0';
- if (strstr(title, "\r"))
- *(strstr(title, "\r")) = '\0';
}
-
- return title;
+ return strcrlftrunc(title);
}
static void update_subscription_finish(const gchar *uri, gchar *feed, gboolean verbose, gchar *error)
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list