Skip to content

Fixes for issues 28 - 36 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/hmrc.4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH hmrc 4 "February 04, 2004"
.TH hmrc 4 "July 10, 2017"
.SH NAME
hmrc \- Hypermail configuration file
.SH DESCRIPTION
Expand Down Expand Up @@ -749,15 +749,15 @@ the index files. This will happen thru a
.B LINK
element in the index document's
.B HEAD.
By default this option is desactivated.
By default this option is disabled.
.TP
.B mcss_url = "URL"
This will link an external stylesheet found at the given URL to
the message files. This will happen thru a
.B LINK
element in the message document's
.B HEAD.
By default this option is desactivated.
By default this option is disabled.
.TP
.B show_headers = list_of_RFC_Headers_to_display
This is the list of headers to be displayed if showheaders is set to
Expand All @@ -766,6 +766,15 @@ line. If it contains the special character ``*''
.B hypermail
will display all header lines.
.TP
.B show_received_date = boolean_number
This controls whether the date the message was received is displayed
at the end of the message text. If set to
.B 0
the received date is not displayed.
This option is
.B enabled
by default.
.TP
.B readone = boolean_number
Set this to
.B 1
Expand Down
9 changes: 9 additions & 0 deletions docs/hmrc.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ <h1 align=center><img src="hypermail.png" width="60" align="middle" height="60"
<li><a href="#show_index_links">show_index_links</a> control links to index pages
<li><a href="#showheaders">showheaders</a> To:, From:, Subject:
<li><a href="#show_headers">show_headers</a> others (Message-ID, etc)
<li><a href="#show_received_date">show_received_date</a> show date message was received
<li><a href="#mhtmlheaderfile">mhtmlheaderfile</a> template
<li><a href="#mhtmlfooterfile">mhtmlfooterfile</a> template
</ul>
Expand Down Expand Up @@ -833,6 +834,14 @@ <h3><a name="msg_head">Message page headers/footers</a></h3>
<br><i>show_headers = From,Subject,Date,Message-ID</i> (disabled by default)
</dd>

<a name="show_received_date"></a>
<dt><strong>show_received_date = [ 0 | 1 ]</strong></dt><dd>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add (enabled by default) comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the example and added the comment, as is done for other options that are enabled by default.

Set this to 0 to disable displaying the date the message was received
at the end of the message body.
<br>
<br><i>show_received_date = 0</i> (enabled by default)
</dd>

<a name="mhtmlheaderfile"></a>
<dt><strong>mhtmlheaderfile = [ path to message header template file | NONE ]</strong></dt><dd>
Set this to the path to the Message header template file. The template
Expand Down
74 changes: 30 additions & 44 deletions src/getname.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,43 @@ char *spamify(char *input)

char *spamify_small(char *input)
{
int insertlen = strlen(set_antispam_at);
/* we should replace the @-letter in the email address */
int newlen = strlen(input) + insertlen;

char *atptr = strchr(input, '@');

if (atptr) {
char *newbuf = malloc(newlen);
int index = atptr - input;
/* copy the part before the @ */
memcpy(newbuf, input, index);
memcpy(newbuf + index, set_antispam_at, insertlen);

/* append the part after the @ */
strcpy(newbuf + index + insertlen, input + index + 1);

/* correct the pointer and free the old */
free(input);
return newbuf;
return replacechar(input, '@', set_antispam_at);
}
/* weird email, bail out */
return input;
}

char *spamify_replacedomain(char *input, char *antispamdomain)
{
/* replace everything after the @-letter in the email address */
int newlen = strlen(input) + strlen(set_antispam_at);
int domainlen = strlen(antispamdomain);

char *atptr = strchr(input, '@');

if (domainlen > 0) {
newlen = newlen + domainlen;
}

if (atptr) {
char *newbuf = malloc(newlen);
int index = atptr - input;
/* copy the part before the @ */
memcpy(newbuf, input, index);
/* append _at_ */
memcpy(newbuf + index, set_antispam_at, strlen(set_antispam_at));
if (domainlen > 0) {
/* append the new domain */
strcpy(newbuf + index + strlen(set_antispam_at), antispamdomain);
}
else {
/* append the part after the @ */
strcpy(newbuf + index + strlen(set_antispam_at), input + index + 1);
}
/* correct the pointer and free the old */
free(input);
return newbuf;
/* replace everything after the @-letter in the email address */
int domainlen = strlen(antispamdomain);
struct Push buff;
int in_ascii = TRUE, esclen = 0;

INIT_PUSH(buff);

for (; *input; input++) {
if (set_iso2022jp) iso2022_state(input, &in_ascii, &esclen);
if (in_ascii == TRUE && *input == '@') {
PushString(&buff, set_antispam_at);
if (domainlen > 0) {
/* append the new domain */
PushString(&buff, antispamdomain);
break;
}
}
else
PushByte(&buff, *input);
}

RETURN_PUSH(buff);
}
/* weird email, bail out */
return input;
Expand Down Expand Up @@ -249,11 +232,14 @@ void getname(char *line, char **namep, char **emailp)
}
else if (*c == '<') { /* Comment may be on the end */
/* From: <[email protected]> Bill Campbell */
c = strchr(line, '>') + 1;
for (i = 0, len = NAMESTRLEN - 1; *c && *c != '\n' && i < len; c++)
name[i++] = *c;
char *c2 = strchr(line, '>');
if (c2 != NULL) {
c = c2 + 1;
for (i = 0, len = NAMESTRLEN - 1; *c && *c != '\n' && i < len; c++)
name[i++] = *c;

comment_fnd = 1;
comment_fnd = 1;
}
}
}
else if (strchr(line, '(')) {
Expand Down
71 changes: 47 additions & 24 deletions src/hypermail.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ char *setindex(char *dfltindex, char *indextype, char *suffix)
return (rp);
}

/*
** Convert locale name to a UTF_8 locale name.
**
** Returns an ALLOCATED string!
*/
static char *utf8locale(char *locale)
{
struct Push buff;

INIT_PUSH(buff); /* init macro */
PushString(&buff, locale);
PushString(&buff, ".UTF-8");
RETURN_PUSH(buff);
} /* end utf8locale() */


/* Print out the version number and die. */

Expand Down Expand Up @@ -365,9 +380,13 @@ int main(int argc, char **argv)
}

#ifdef HAVE_LOCALE_H
if (!setlocale(LC_ALL, locale_code)) {
if (!setlocale(LC_ALL, locale_code)) {
char *locale_code_utf8 = utf8locale(locale_code);
if (!setlocale(LC_ALL, locale_code_utf8)) {
snprintf(errmsg, sizeof(errmsg), "WARNING: locale \"%s\", not supported.\n", locale_code);
fprintf(stderr, "%s", errmsg);/* AUDIT biege: avoid format-bug warning */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch look s ok. Could you explain what is "AUDIT biege"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. That's not code that I added or touched.

}
free(locale_code_utf8);
}
#endif

Expand Down Expand Up @@ -604,6 +623,7 @@ int main(int argc, char **argv)
}
if (set_increment) {
int num_displayable;
int num_added;
if (set_linkquotes)
replylist = NULL;
/* we have to start with the msgnum - 1 so that the rest of the
Expand All @@ -613,29 +633,32 @@ int main(int argc, char **argv)
amount_old = max_msgnum + 1; /* counts gaps as messages */

/* start numbering at this number */
amount_new = num_displayable + parsemail(set_mbox, use_stdin, set_readone, set_increment, set_dir, set_inlinehtml, amount_old);
if (set_linkquotes)
analyze_headers(max_msgnum + 1);

/* write the index of msgno/msgid_hash filenames */
if (set_nonsequential)
write_messageindex(0, max_msgnum + 1);

writearticles(amount_old, max_msgnum + 1);

/* JK: in function of other hypermail configuration options,
delete_incremental will continuous escape and add more markup
to non-deleted messages that are replies to deleted messages.
Thus, a setup option to disable it */
if (set_delete_incremental && deletedlist)
update_deletions(amount_old);

if (set_show_msg_links) {
fixnextheader(set_dir, amount_old, -1);
for (i = amount_old; i <= max_msgnum; ++i) {
if (set_showreplies)
fixreplyheader(set_dir, i, 0, amount_old);
fixthreadheader(set_dir, i, amount_old);
num_added = parsemail(set_mbox, use_stdin, set_readone, set_increment, set_dir, set_inlinehtml, amount_old);
if (num_added > 0) {
amount_new = num_displayable + num_added;
if (set_linkquotes)
analyze_headers(max_msgnum + 1);

/* write the index of msgno/msgid_hash filenames */
if (set_nonsequential)
write_messageindex(0, max_msgnum + 1);

writearticles(amount_old, max_msgnum + 1);

/* JK: in function of other hypermail configuration options,
delete_incremental will continuous escape and add more markup
to non-deleted messages that are replies to deleted messages.
Thus, a setup option to disable it */
if (set_delete_incremental && deletedlist)
update_deletions(amount_old);

if (set_show_msg_links) {
fixnextheader(set_dir, amount_old, -1);
for (i = amount_old; i <= max_msgnum; ++i) {
if (set_showreplies)
fixreplyheader(set_dir, i, 0, amount_old);
fixthreadheader(set_dir, i, amount_old);
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
else if (!strcasecmp("b", encoding)) {
/* base64 decoding */
int len;
size_t charsetlen;
#ifdef HAVE_ICONV
size_t tmplen;
char *output2;
Expand All @@ -926,7 +927,9 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
memcpy(output,output2,tmplen);
output += tmplen;
free(output2);
memcpy(charsetsave,charset,strlen(charset)<255 ? strlen(charset) : 255 );
charsetlen = strlen(charset) < 255 ? strlen(charset) : 255;
memcpy(charsetsave,charset,charsetlen);
charsetsave[charsetlen] = '\0';
#else
base64Decode(ptr, output, &len);
output += len;
Expand Down
12 changes: 8 additions & 4 deletions src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,10 +1238,12 @@ void printbody(FILE *fp, struct emailinfo *email, int maybe_reply, int is_reply)

if (!set_showhtml) {
fprintf(fp, "<pre id=\"body\">\n");
fprintf(fp, "<a name=\"start%d\" accesskey=\"j\" id=\"start%d\"></a>", email->msgnum,email->msgnum);
pre = TRUE;
}

/* tag the start of the message body */
fprintf(fp, "<a name=\"start%d\" accesskey=\"j\" id=\"start%d\"></a>", email->msgnum,email->msgnum);

if (set_showhtml == 2)
init_txt2html();
inquote = 0;
Expand Down Expand Up @@ -2263,8 +2265,9 @@ void writearticles(int startnum, int maxnum)
fprintf (fp, "<div class=\"mail\">\n");
print_headers(fp, email, FALSE);
printbody(fp, email, maybe_reply, is_reply);
fprintf (fp, "<span id=\"received\"><dfn>%s</dfn> %s</span>\n",
lang[MSG_RECEIVED_ON], getdatestr(email->fromdate));
if (set_show_received_date)
fprintf (fp, "<span id=\"received\"><dfn>%s</dfn> %s</span>\n",
lang[MSG_RECEIVED_ON], getdatestr(email->fromdate));
fprintf (fp, "</div>\n");
printcomment(fp, "body", "end");

Expand Down Expand Up @@ -3214,7 +3217,8 @@ void write_toplevel_indices(int amountmsgs)
char *index_title;
char *filename;
char *saved_set_dateformat;
char *abbr_dateformat = "%d %b %Y";
char *abbr_dateformat = set_describe_folder != NULL ?
set_describe_folder : "%d %b %Y";
char *verbose_dateformat = "%A, %e %B %Y";

char *tmpstr;
Expand Down
6 changes: 6 additions & 0 deletions src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool set_showheaders;
bool set_showbr;
bool set_showhr;
bool set_showreplies;
bool set_show_received_date;
int set_show_msg_links;
int set_show_index_links;
bool set_usetable;
Expand Down Expand Up @@ -309,6 +310,10 @@ struct Config cfg[] = {
"# Set this to On to show all replies to a message as links\n"
"# in article files.\n", FALSE},

{"show_received_date", &set_show_received_date, BTRUE, CFG_SWITCH,
"# Set this to On to show the Received date at the end of the message\n"
"# body.\n", FALSE},

{"show_msg_links", &set_show_msg_links, INT(1), CFG_INTEGER,
"# Set this to 1 to put the individual message links at the top\n"
"# of the individual message pages. Set this to 0 to produce pages\n"
Expand Down Expand Up @@ -1250,6 +1255,7 @@ void dump_config(void)
printf("set_showbr = %d\n",set_showbr);
printf("set_showhr = %d\n",set_showhr);
printf("set_showreplies = %d\n",set_showreplies);
printf("set_show_received_date = %d\n",set_show_received_date);
printf("set_show_msg_links = %d\n",set_show_msg_links);
printf("set_usetable = %d\n",set_usetable);
printf("set_indextable = %d\n",set_indextable);
Expand Down
1 change: 1 addition & 0 deletions src/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extern bool set_showheaders;
extern bool set_showbr;
extern bool set_showhr;
extern bool set_showreplies;
extern bool set_show_received_date;
extern int set_show_msg_links;
extern int set_show_index_links;
extern bool set_usetable;
Expand Down
Loading