commit 3a89a270fcad59901d8fcdc901ac03523c6aeb03
parent 8395c4c673c7d313f24050d030491412e808192c
Author: Ricardo Mones <ricardo@mones.org>
Date: Mon, 22 Aug 2016 19:02:47 +0200
Fix bug #2975: Implement setting -0000 timezone to hide sender localtime
This adds a new hidden preference, namely 'hide_timezone', that
sets the timezone of date fields sent over the network to the
unknown timezone value as specified in RFC 5322 ยง3.3.
Default value is false (i.e., send available timezone information).
Diffstat:
6 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/common/utils.c b/src/common/utils.c
@@ -3557,7 +3557,7 @@ gchar *tzoffset(time_t *now)
return offset_string;
}
-void get_rfc822_date(gchar *buf, gint len)
+static void _get_rfc822_date(gchar *buf, gint len, gboolean hidetz)
{
struct tm *lt;
time_t t;
@@ -3573,7 +3573,17 @@ void get_rfc822_date(gchar *buf, gint len)
day, mon, &dd, &hh, &mm, &ss, &yyyy);
g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
- day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
+ day, dd, mon, yyyy, hh, mm, ss, (hidetz? "-0000": tzoffset(&t)));
+}
+
+void get_rfc822_date(gchar *buf, gint len)
+{
+ _get_rfc822_date(buf, len, FALSE);
+}
+
+void get_rfc822_date_hide_tz(gchar *buf, gint len)
+{
+ _get_rfc822_date(buf, len, TRUE);
}
void debug_set_mode(gboolean mode)
diff --git a/src/common/utils.h b/src/common/utils.h
@@ -520,6 +520,8 @@ time_t tzoffset_sec (time_t *now);
gchar *tzoffset (time_t *now);
void get_rfc822_date (gchar *buf,
gint len);
+void get_rfc822_date_hide_tz (gchar *buf,
+ gint len);
size_t fast_strftime (gchar *buf,
gint buflen,
diff --git a/src/compose.c b/src/compose.c
@@ -5382,7 +5382,10 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
cm_return_val_if_fail(compose->account->address != NULL, -1);
/* Resent-Date */
- get_rfc822_date(buf, sizeof(buf));
+ if (prefs_common.hide_timezone)
+ get_rfc822_date_hide_tz(buf, sizeof(buf));
+ else
+ get_rfc822_date(buf, sizeof(buf));
err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
/* Resent-From */
@@ -6459,7 +6462,10 @@ static gchar *compose_get_header(Compose *compose)
header = g_string_sized_new(64);
/* Date */
- get_rfc822_date(buf, sizeof(buf));
+ if (prefs_common.hide_timezone)
+ get_rfc822_date_hide_tz(buf, sizeof(buf));
+ else
+ get_rfc822_date(buf, sizeof(buf));
g_string_append_printf(header, "Date: %s\n", buf);
/* From */
diff --git a/src/news.c b/src/news.c
@@ -945,7 +945,10 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
g_warning("can't change file mode");
}
- get_rfc822_date(buf, sizeof(buf));
+ if (prefs_common.hide_timezone)
+ get_rfc822_date_hide_tz(buf, sizeof(buf));
+ else
+ get_rfc822_date(buf, sizeof(buf));
if (fprintf(tmpfp, "From: %s\r\n"
"Newsgroups: %s\r\n"
"Subject: cmsg cancel <%s>\r\n"
diff --git a/src/prefs_common.c b/src/prefs_common.c
@@ -199,9 +199,10 @@ static PrefParam param[] = {
NULL, NULL, NULL},
{"outgoing_fallback_to_ascii", "TRUE", &prefs_common.outgoing_fallback_to_ascii, P_BOOL,
NULL, NULL, NULL},
- {"warn_empty_subj", "TRUE", &prefs_common.warn_empty_subj,
+ {"warn_empty_subj", "TRUE", &prefs_common.warn_empty_subj,
+ P_BOOL, NULL, NULL, NULL},
+ {"hide_timezone", "FALSE", &prefs_common.hide_timezone,
P_BOOL, NULL, NULL, NULL},
-
{"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
P_BOOL, NULL, NULL, NULL},
diff --git a/src/prefs_common.h b/src/prefs_common.h
@@ -143,7 +143,7 @@ struct _PrefsCommon
TransferEncodingMethod encoding_method;
gboolean outgoing_fallback_to_ascii;
gboolean warn_empty_subj;
-
+ gboolean hide_timezone;
gboolean allow_jisx0201_kana;
/* Compose */