/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto & The Sylpheed-Claws Team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto & The Claws Mail Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
gb_format = _("%.2fGB");
}
- if (size < 1024) {
+ if (size < (off_t)1024) {
g_snprintf(str, sizeof(str), b_format, (gint)size);
return str;
- } else if (size >> 10 < 1024) {
+ } else if (size >> 10 < (off_t)1024) {
divide(size, 10, t, r);
g_snprintf(str, sizeof(str), kb_format, t, r);
return str;
- } else if (size >> 20 < 1024) {
+ } else if (size >> 20 < (off_t)1024) {
divide(size, 20, t, r);
g_snprintf(str, sizeof(str), mb_format, t, r);
return str;
}
gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
- gchar **subject, gchar **body)
+ gchar **subject, gchar **body, gchar **attach)
{
gchar *tmp_mailto;
gchar *p;
+ const gchar *forbidden_uris[] = { ".gnupg/",
+ "/etc/passwd",
+ "/etc/shadow",
+ NULL };
Xstrdup_a(tmp_mailto, mailto, return -1);
} else if (body && !*body && !g_ascii_strcasecmp(field, "body")) {
*body = g_malloc(strlen(value) + 1);
decode_uri(*body, value);
+ } else if (attach && !*attach && !g_ascii_strcasecmp(field, "attach")) {
+ int i = 0;
+ *attach = g_malloc(strlen(value) + 1);
+ decode_uri(*attach, value);
+ for (; forbidden_uris[i]; i++) {
+ if (strstr(*attach, forbidden_uris[i])) {
+ printf("Refusing to attach '%s', potential private data leak\n",
+ *attach);
+ g_free(*attach);
+ *attach = NULL;
+ break;
+ }
+ }
}
}
if (!plugin_dir)
plugin_dir = g_strconcat(w32_get_module_dir(),
- "\\lib\\sylpheed-claws\\plugins\\",
+ "\\lib\\claws-mail\\plugins\\",
NULL);
return plugin_dir;
#else
tmplen = strlen(tmpdir);
progname = g_get_prgname();
if (progname == NULL)
- progname = "sylpheed-claws";
+ progname = "claws-mail";
proglen = strlen(progname);
Xalloca(fname, tmplen + 1 + proglen + sizeof(suffix),
return tmpfile());
{
int fd;
#ifdef G_OS_WIN32
- char *template = g_strdup_printf ("%s%csylpheed.XXXXXX",
+ char *template = g_strdup_printf ("%s%cclaws.XXXXXX",
dir, G_DIR_SEPARATOR);
fd = mkstemp_name(template, filename);
g_free(template);
#else
- *filename = g_strdup_printf("%s%csylpheed.XXXXXX", dir, G_DIR_SEPARATOR);
+ *filename = g_strdup_printf("%s%cclaws.XXXXXX", dir, G_DIR_SEPARATOR);
fd = mkstemp(*filename);
#endif
return fdopen(fd, "w+");
return str;
}
-gint execute_async(gchar *const argv[])
+static gint execute_async(gchar *const argv[])
{
g_return_val_if_fail(argv != NULL && argv[0] != NULL, -1);
return 0;
}
-gint execute_sync(gchar *const argv[])
+static gint execute_sync(gchar *const argv[])
{
gint status;
}
}
-void encode_uri(gchar *encoded_uri, gint bufsize, const gchar *uri)
+static void encode_uri(gchar *encoded_uri, gint bufsize, const gchar *uri)
{
int i;
int k;
while (fgets(buf, sizeof (buf), fp) != NULL) {
gchar **parts = g_strsplit(buf, ";", 3);
gchar *trimmed = parts[0];
- while (trimmed[0] == ' ')
+ while (trimmed[0] == ' ' || trimmed[0] == '\t')
trimmed++;
- while (trimmed[strlen(trimmed)-1] == ' ')
+ while (trimmed[strlen(trimmed)-1] == ' ' || trimmed[strlen(trimmed)-1] == '\t')
trimmed[strlen(trimmed)-1] = '\0';
if (!strcmp(trimmed, type)) {
gchar *testcmd = orig_testcmd;
if (strstr(testcmd,";"))
*(strstr(testcmd,";")) = '\0';
- while (testcmd[0] == ' ')
+ while (testcmd[0] == ' ' || testcmd[0] == '\t')
testcmd++;
while (testcmd[strlen(testcmd)-1] == '\n')
testcmd[strlen(testcmd)-1] = '\0';
while (testcmd[strlen(testcmd)-1] == '\r')
testcmd[strlen(testcmd)-1] = '\0';
- while (testcmd[strlen(testcmd)-1] == ' ')
+ while (testcmd[strlen(testcmd)-1] == ' ' || testcmd[strlen(testcmd)-1] == '\t')
testcmd[strlen(testcmd)-1] = '\0';
if (strstr(testcmd, "%s")) {
}
trimmed = parts[1];
- while (trimmed[0] == ' ')
+ while (trimmed[0] == ' ' || trimmed[0] == '\t')
trimmed++;
while (trimmed[strlen(trimmed)-1] == '\n')
trimmed[strlen(trimmed)-1] = '\0';
while (trimmed[strlen(trimmed)-1] == '\r')
trimmed[strlen(trimmed)-1] = '\0';
- while (trimmed[strlen(trimmed)-1] == ' ')
+ while (trimmed[strlen(trimmed)-1] == ' ' || trimmed[strlen(trimmed)-1] == '\t')
trimmed[strlen(trimmed)-1] = '\0';
result = g_strdup(trimmed);
g_strfreev(parts);
FILE *outfp = fopen(outpath, "wb");
gchar buf[BUFFSIZE];
- if (!fp) {
- g_free(path);
- g_free(outpath);
- return;
- }
if (!outfp) {
g_free(path);
g_free(outpath);
fclose(fp);
return;
}
- while (fgets(buf, sizeof (buf), fp) != NULL) {
+ while (fp && fgets(buf, sizeof (buf), fp) != NULL) {
gchar **parts = g_strsplit(buf, ";", 3);
gchar *trimmed = parts[0];
while (trimmed[0] == ' ')
g_strfreev(parts);
}
fprintf(outfp, "%s; %s\n", type, command);
- fclose(fp);
+
+ if (fp)
+ fclose(fp);
+
fclose(outfp);
g_rename(outpath, path);
}
debug_print("copying: %s -> %s\n", old_file, new_file);
if (g_file_test(old_file, G_FILE_TEST_IS_REGULAR)) {
gint r = copy_file(old_file, new_file, TRUE);
- if (r < 0)
+ if (r < 0) {
+ g_dir_close(dir);
return r;
+ }
+ } else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
+ GError *error;
+ gint r = 0;
+ gchar *target = g_file_read_link(old_file, &error);
+ if (target)
+ r = symlink(target, new_file);
+ g_free(target);
+ if (r < 0) {
+ g_dir_close(dir);
+ return r;
+ }
} else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
gint r = copy_dir(old_file, new_file);
- if (r < 0)
+ if (r < 0) {
+ g_dir_close(dir);
return r;
+ }
}
}
+ g_dir_close(dir);
return 0;
}