Skip to content

Commit efb4aaf

Browse files
author
Peter McCluskey
committed
Add filename_base option.
1 parent c4757f8 commit efb4aaf

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed

Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Version Changes for Hypermail
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Peter McCluskey (Nov 28, 2004)
4+
Add filename_base option.
5+
36
Peter McCluskey (Sep 29, 2004)
47
Add support for JAVT timezone.
58
Add mailbox_date_trimmer to contrib, faq.

configs/hmrc.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,3 +879,13 @@ show_index_links = 1
879879
# in the future.
880880

881881
# use_sender_date = 0
882+
883+
# filename_base = string
884+
#
885+
# This option overrides the normal rules for creating attachment
886+
# file names, and creates file names from the string that this
887+
# option is set to plus a file name extension if one can be found
888+
# in the name supplied by the message. This option is mainly for
889+
# languages that use different character sets from English.
890+
891+
# filename_base =

docs/hmrc.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ <h1 align=center><img src="hypermail.png" width="60" align="middle" height="60"
129129
<li><a href="#unsafe_chars">unsafe_chars</a> restrict filename chars
130130
<li><a href="#save_alts">save_alts</a> multipart/alternative handling
131131
<li><a href="#alts_text">alts_text</a> text for some save_alts choices
132+
<li><a href="#filename_base">filename_base</a> attachment file name
132133
</ul>
133134

134135
<li><a href="#sysadmin">System Administration</a>
@@ -157,6 +158,7 @@ <h1 align=center><img src="hypermail.png" width="60" align="middle" height="60"
157158
<li><a href="#htmlsuffix">htmlsuffix</a> .html, .htm, etc
158159
<li><a href="#dirmode">dirmode</a> chmod directories
159160
<li><a href="#filemode">filemode</a> chmod html files
161+
<li><a href="#filename_base">filename_base</a> attachment file name
160162
</ul>
161163
<li><a href="#sysmisc">Miscellaneous</a>
162164
<ul>
@@ -1117,6 +1119,17 @@ <h3><a name="files">Filesystem output</a></h3>
11171119
<br><i>filemode = 0644</i>
11181120
</dd>
11191121

1122+
<a name="filename_base"></a>
1123+
<dt><strong>filename_base = [ string ]</strong></dt><dd>
1124+
This option overrides the normal rules for creating attachment
1125+
file names, and creates file names from the string that this
1126+
option is set to plus a file name extension if one can be found
1127+
in the name supplied by the message. This option is mainly for
1128+
languages that use different character sets from English.
1129+
<br>
1130+
<br><i>filename_base = attachment</i> (disabled by default)
1131+
</dd>
1132+
11201133
<h3><a name="sysmisc">System miscellaneous</a></h3>
11211134

11221135
<a name="usegdbm"></a>

src/parse.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,26 @@ char *safe_filename(char *name)
302302
return name;
303303
}
304304

305+
static void
306+
create_attachname(char *attachname, int max_len)
307+
{
308+
int i, max_i;
309+
char suffix[8];
310+
max_i = strlen(attachname);
311+
if(max_i >= max_len)
312+
max_i = max_len - 1;
313+
i = max_i;
314+
while(i >= 0 && i > max_i - sizeof(suffix) && attachname[i] != '.')
315+
--i;
316+
if(i >= 0 && attachname[i] == '.')
317+
strncpy(suffix, attachname + i, sizeof(suffix) - 1);
318+
else
319+
suffix[0] = 0;
320+
strncpy(attachname, set_filename_base, max_len);
321+
strncat(attachname, suffix, max_len - strlen(attachname) - 1);
322+
safe_filename(attachname);
323+
}
324+
305325
/*
306326
** Cross-indexes - adds to a list of replies. If a message is a reply to
307327
** another, the number of the message it's replying to is added to the list.
@@ -2395,6 +2415,8 @@ msgid);
23952415
if (att_counter > 99)
23962416
binname = NULL;
23972417
else {
2418+
if (set_filename_base)
2419+
create_attachname(attachname, sizeof(attachname));
23982420
if (attachname[0])
23992421
fname = attachname;
24002422
else

src/setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ char *set_mhtmlheader;
130130
char *set_mhtmlfooter;
131131
char *set_attachmentlink;
132132
char *set_unsafe_chars;
133+
char *set_filename_base;
133134

134135
char *set_folder_by_date;
135136
char *set_latest_folder;
@@ -774,6 +775,13 @@ struct Config cfg[] = {
774775
"# message was received, for purposes such as putting in folders\n"
775776
"# or sorting. Details of which purposes this affects may change\n"
776777
"# in the future.\n", FALSE},
778+
779+
{"filename_base", &set_filename_base, NULL, CFG_STRING,
780+
"# This option overrides the normal rules for creating attachment\n"
781+
"# file names, and creates file names from the string that this\n"
782+
"# option is set to plus a file name extension if one can be found\n"
783+
"# in the name supplied by the message. This option is mainly for\n"
784+
"# languages that use different character sets from English.\n", FALSE},
777785
};
778786

779787
/* ---------------------------------------------------------------- */

src/setup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ extern char *set_mhtmlfooter;
145145

146146
extern char *set_attachmentlink;
147147
extern char *set_unsafe_chars;
148+
extern char *set_filename_base;
148149
extern bool set_linkquotes;
149150

150151
extern char *set_antispamdomain;

0 commit comments

Comments
 (0)