[Commits] [SCM] claws branch, master, updated. 3.11.1-187-g567b040
ticho at claws-mail.org
ticho at claws-mail.org
Wed Jul 1 20:38:02 CEST 2015
The branch, master has been updated
via 567b040b6b814b6d6f01bf1a59adb1865f623511 (commit)
from 95c770f2fdf65e0506333e2dd00f8855a2c4ae65 (commit)
Summary of changes:
src/alertpanel.h | 1 +
src/folder.c | 13 +++++++++++++
src/folder.h | 2 ++
src/foldersel.c | 5 +++++
src/mh_gtk.c | 6 ++++++
src/plugins/mailmbox/plugin_gtk.c | 16 ++++++++++++++--
src/plugins/rssyl/rssyl_cb_menu.c | 15 ++++++++++++++-
src/plugins/rssyl/rssyl_subscribe.c | 9 +++++++++
8 files changed, 64 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 567b040b6b814b6d6f01bf1a59adb1865f623511
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Wed Jul 1 20:37:00 2015 +0200
Disallow folder names to begin or end with a dot on Windows.
I fixed the most obvious locations - MH, RSSyl, mbox. There
may be more.
diff --git a/src/alertpanel.h b/src/alertpanel.h
index 800c48e..4a461ad 100644
--- a/src/alertpanel.h
+++ b/src/alertpanel.h
@@ -21,6 +21,7 @@
#define __ALERTPANEL_H__
#include <glib.h>
+#include <gtk/gtk.h>
typedef enum
{
diff --git a/src/folder.c b/src/folder.c
index 4bd2447..06f12cb 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -36,6 +36,7 @@
#include <w32lib.h>
#endif
+#include "alertpanel.h"
#include "folder.h"
#include "session.h"
#include "inc.h"
@@ -4811,3 +4812,15 @@ gint folder_item_search_msgs_local (Folder *folder,
return matched_count;
}
+/* Tests if a local (on disk) folder name is acceptable. */
+gboolean folder_local_name_ok(const gchar *name)
+{
+#ifdef G_OS_WIN32
+ if (name[0] == '.' || new_folder[strlen(name) - 1]) {
+ alertpanel_error(_("A folder name cannot begin or end with a dot.");
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
diff --git a/src/folder.h b/src/folder.h
index e0ad21a..69c0538 100644
--- a/src/folder.h
+++ b/src/folder.h
@@ -1005,4 +1005,6 @@ gint folder_item_search_msgs_local (Folder *folder,
gpointer progress_data);
gchar *folder_get_list_path (void);
+gboolean folder_local_name_ok(const gchar *name);
+
#endif /* __FOLDER_H__ */
diff --git a/src/foldersel.c b/src/foldersel.c
index ac3cdf1..e618d41 100644
--- a/src/foldersel.c
+++ b/src/foldersel.c
@@ -597,6 +597,11 @@ static void foldersel_new_folder(GtkButton *button, gpointer data)
return;
}
+ if (FOLDER_TYPE(selected_item->folder) != F_IMAP &&
+ FOLDER_TYPE(selected_item->folder) != F_NEWS &&
+ !folder_local_name_ok(new_folder))
+ return;
+
disp_name = trim_string(new_folder, 32);
AUTORELEASE_STR(disp_name, {g_free(disp_name); return;});
diff --git a/src/mh_gtk.c b/src/mh_gtk.c
index 2995f01..d5f0fd5 100644
--- a/src/mh_gtk.c
+++ b/src/mh_gtk.c
@@ -157,6 +157,9 @@ static void new_folder_cb(GtkAction *action, gpointer data)
return;
}
+ if (!folder_local_name_ok(new_folder))
+ return;
+
name = trim_string(new_folder, 32);
AUTORELEASE_STR(name, {g_free(name); return;});
@@ -263,6 +266,9 @@ static void rename_folder_cb(GtkAction *action, gpointer data)
return;
}
+ if (!folder_local_name_ok(new_folder))
+ return;
+
if (folder_find_child_item_by_name(folder_item_parent(item), new_folder)) {
name = trim_string(new_folder, 32);
alertpanel_error(_("The folder '%s' already exists."), name);
diff --git a/src/plugins/mailmbox/plugin_gtk.c b/src/plugins/mailmbox/plugin_gtk.c
index e6b30f5..0ca7336 100644
--- a/src/plugins/mailmbox/plugin_gtk.c
+++ b/src/plugins/mailmbox/plugin_gtk.c
@@ -198,13 +198,19 @@ static void add_mailbox(GtkAction *action, gpointer callback_data)
return;
}
basename = g_path_get_basename(path);
+
+ if (!folder_local_name_ok(basename)) {
+ g_free(path);
+ g_free(basename);
+ return;
+ }
+
folder = folder_new(folder_get_class_from_string("mailmbox"),
!strcmp(path, "Mail") ? _("Mailbox") : basename,
path);
- g_free(basename);
+ g_free(basename);
g_free(path);
-
if (folder->klass->create_tree(folder) < 0) {
alertpanel_error(_("Creation of the mailbox failed.\n"
"Maybe some files already exist, or you don't have the permission to write there."));
@@ -251,6 +257,9 @@ static void new_folder_cb(GtkAction *action, gpointer data)
return;
}
+ if (!folder_local_name_ok(new_folder))
+ return;
+
name = trim_string(new_folder, 32);
AUTORELEASE_STR(name, {g_free(name); return;});
@@ -418,6 +427,9 @@ static void rename_folder_cb(GtkAction *action, gpointer data)
return;
}
+ if (!folder_local_name_ok(new_folder))
+ return;
+
parent = folder_item_parent(item);
p = g_strconcat(parent->path ? parent->path : "", ".", new_folder, NULL);
if (folder_find_child_item_by_name(parent, p)) {
diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c
index 1a30f04..771791b 100644
--- a/src/plugins/rssyl/rssyl_cb_menu.c
+++ b/src/plugins/rssyl/rssyl_cb_menu.c
@@ -103,6 +103,11 @@ void rssyl_new_folder_cb(GtkAction *action,
return;
}
+ if (!folder_local_name_ok(new_folder)) {
+ g_free(new_folder);
+ return;
+ }
+
/* Find an unused name for new folder */
/* TODO: Perhaps stop after X attempts? */
tmp = g_strdup(new_folder);
@@ -198,11 +203,16 @@ void rssyl_rename_cb(GtkAction *action,
g_free(message);
g_free(name);
if (!new_folder) return;
- AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
alertpanel_error(_("'%c' can't be included in folder name."),
G_DIR_SEPARATOR);
+ g_free(new_folder);
+ return;
+ }
+
+ if (!folder_local_name_ok(new_folder)) {
+ g_free(new_folder);
return;
}
@@ -210,14 +220,17 @@ void rssyl_rename_cb(GtkAction *action,
name = trim_string(new_folder, 32);
alertpanel_error(_("The folder '%s' already exists."), name);
g_free(name);
+ g_free(new_folder);
return;
}
if (folder_item_rename(item, new_folder) < 0) {
alertpanel_error(_("The folder could not be renamed.\n"
"The new folder name is not allowed."));
+ g_free(new_folder);
return;
}
+ g_free(new_folder);
folder_item_prefs_save_config(item);
folder_write_list();
diff --git a/src/plugins/rssyl/rssyl_subscribe.c b/src/plugins/rssyl/rssyl_subscribe.c
index 7cc30e9..b9dbc43 100644
--- a/src/plugins/rssyl/rssyl_subscribe.c
+++ b/src/plugins/rssyl/rssyl_subscribe.c
@@ -127,6 +127,15 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
/* Create a folder for it. */
tmpname = rssyl_format_string(ctx->feed->title, TRUE, TRUE);
tmpname2 = g_strdup(tmpname);
+
+#ifdef G_OS_WIN32
+ /* Windows does not allow its filenames to start or end with a dot. */
+ if (tmpname2[0] == '.')
+ tmpname2[0] = "_";
+ if (tmpname2[strlen(tmpname2) - 1] == '.')
+ tmpname2[strlen(tmpname2) - 1] == '_';
+#endif
+
while (folder_find_child_item_by_name(parent, tmpname2) != 0 && i < 20) {
debug_print("RSSyl: Folder '%s' already exists, trying another name\n",
tmpname2);
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list