Added subject line cleaner

This commit is contained in:
Michiel Broek 2005-08-10 15:32:42 +00:00
parent abdbbc862e
commit ccfd32e420
11 changed files with 150 additions and 106 deletions

View File

@ -6,6 +6,10 @@ v0.71.3 13-Jun-2005
upgrade: upgrade:
Check mbsetup 7.n.3.14 and 7.n.3.15 settings. Check mbsetup 7.n.3.14 and 7.n.3.15 settings.
mbselib.a:
Added a function to clean subject lines from garbage, trailing
spaces etc. to improve message linking.
mbcico: mbcico:
Added support for binkp GZ and BZ2 compression. Can be turned Added support for binkp GZ and BZ2 compression. Can be turned
off per node. Only effective with originating calls. Incoming off per node. Only effective with originating calls. Incoming
@ -14,12 +18,14 @@ v0.71.3 13-Jun-2005
mbsebbs: mbsebbs:
Added logging of remote host and terminal. Added logging of remote host and terminal.
Added subject line clean in several places.
mbnewuser: mbnewuser:
Added logging of remote host and terminal. Added logging of remote host and terminal.
mbfido: mbfido:
Fixed commandline parser for mail recipients. Fixed commandline parser for mail recipients.
Added subject line clean in several places.
mbsetup: mbsetup:
Added setup switches per node to disable PLZ or GZ and BZ2 Added setup switches per node to disable PLZ or GZ and BZ2

3
TODO
View File

@ -126,9 +126,6 @@ mbfido:
N: Make mailhistory.html a lot shorter, maybe day or week versions. N: Make mailhistory.html a lot shorter, maybe day or week versions.
N: Strip trailing spaces from subject lines to make sure reply linking
works.
mbcico: mbcico:
L: Implement binkp option ND. L: Implement binkp option ND.

View File

@ -2345,7 +2345,8 @@ unsigned char mbse_Readkey(void); /* Read a translated key */
*/ */
char *padleft(char *str, int size, char pad); char *padleft(char *str, int size, char pad);
char *tl(char *str); char *tl(char *str);
void Striplf(char *String); void Striplf(char *);
void mbse_CleanSubject(char *);
void tlf(char *str); void tlf(char *str);
char *tu(char *str); char *tu(char *str);
char *tlcap(char *); char *tlcap(char *);

View File

@ -83,6 +83,35 @@ void Striplf(char *String)
void mbse_CleanSubject(char *String)
{
int i, fixed = FALSE;
i = strlen(String) -1;
while ((isspace(String[i])) && i) {
String[i] = '\0';
i--;
fixed = TRUE;
}
if ((strncasecmp(String, "Re: ", 4) == 0) && (strncmp(String, "Re: ", 4))) {
/*
* Fix Re:
*/
String[0] = 'R';
String[1] = 'e';
String[2] = ':';
String[3] = ' ';
fixed = TRUE;
}
if (fixed)
Syslog('m', "Fixed subj: \"%s\"", printable(String, 0));
}
/* /*
* Converts first letter to UpperCase * Converts first letter to UpperCase
*/ */

View File

@ -50,6 +50,8 @@ int Post(char *To, long Area, char *Subj, char *File, char *Flavor)
time_t tt; time_t tt;
struct tm *t; struct tm *t;
mbse_CleanSubject(Subj);
if (!do_quiet) { if (!do_quiet) {
mbse_colour(3, 0); mbse_colour(3, 0);
printf("Post \"%s\" to \"%s\" in area %ld\n", File, To, Area); printf("Post \"%s\" to \"%s\" in area %ld\n", File, To, Area);

View File

@ -4,7 +4,7 @@
* Purpose ...............: Import a echomail message * Purpose ...............: Import a echomail message
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -56,113 +56,114 @@ extern int do_quiet; /* Quiet flag */
*/ */
int storeecho(faddr *f, faddr *t, time_t mdate, int flags, char *subj, char *msgid, char *reply, int bad, int dupe, FILE *fp) int storeecho(faddr *f, faddr *t, time_t mdate, int flags, char *subj, char *msgid, char *reply, int bad, int dupe, FILE *fp)
{ {
int result; int result;
unsigned long crc2; unsigned long crc2;
char *buf; char *buf;
/* mbse_CleanSubject(subj);
* Update import counters
*/
if (!bad && !dupe) {
StatAdd(&msgs.Received, 1L);
msgs.LastRcvd = time(NULL);
StatAdd(&mgroup.MsgsRcvd, 1L);
mgroup.LastDate = time(NULL);
UpdateMsgs();
}
if (bad) { /*
if (strlen(CFG.badboard) == 0) { * Update import counters
Syslog('+', "Killing bad message"); */
return 0; if (!bad && !dupe) {
} else { StatAdd(&msgs.Received, 1L);
if ((result = Msg_Open(CFG.badboard))) msgs.LastRcvd = time(NULL);
Syslog('+', "Tossing in bad board"); StatAdd(&mgroup.MsgsRcvd, 1L);
} mgroup.LastDate = time(NULL);
} else if (dupe) { UpdateMsgs();
if (strlen(CFG.dupboard) == 0) { }
Syslog('+', "Killing dupe message");
return 0; if (bad) {
} else { if (strlen(CFG.badboard) == 0) {
if ((result = Msg_Open(CFG.dupboard))) Syslog('+', "Killing bad message");
Syslog('+', "Tossing in dupe board"); return 0;
}
} else { } else {
result = Msg_Open(msgs.Base); if ((result = Msg_Open(CFG.badboard)))
Syslog('+', "Tossing in bad board");
} }
if (!result) { } else if (dupe) {
WriteError("Can't open JAMmb %s", msgs.Base); if (strlen(CFG.dupboard) == 0) {
return 1; Syslog('+', "Killing dupe message");
} return 0;
if (Msg_Lock(30L)) {
if (dupe)
echo_dupe++;
else if (bad)
echo_bad++;
else
echo_imp++;
if (!do_quiet) {
mbse_colour(3, 0);
printf("\r%6u => %-40s\r", echo_in, msgs.Name);
fflush(stdout);
}
Msg_New();
/*
* Fill subfields
*/
strcpy(Msg.From, f->name);
strcpy(Msg.To, t->name);
strcpy(Msg.FromAddress, ascfnode(f,0x1f));
strcpy(Msg.Subject, subj);
Msg.Written = mdate;
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Echomail = TRUE;
/*
* These are the only usefull flags in echomail
*/
if ((flags & M_PVT) && ((msgs.MsgKinds == BOTH) || (msgs.MsgKinds == PRIVATE)))
Msg.Private = TRUE;
if (flags & M_FILE)
Msg.FileAttach = TRUE;
/*
* Set MSGID and REPLY crc.
*/
if (msgid != NULL) {
crc2 = -1;
Msg.MsgIdCRC = upd_crc32(msgid, crc2, strlen(msgid));
}
if (reply != NULL) {
crc2 = -1;
Msg.ReplyCRC = upd_crc32(reply, crc2, strlen(reply));
}
/*
* Start write the message
* If not a bad or dupe message, eat the first
* line (AREA:tag).
*/
buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
rewind(fp);
if (!dupe && !bad)
fgets(buf , MAX_LINE_LENGTH, fp);
Msg_Write(fp);
Msg_AddMsg();
Msg_UnLock();
Msg_Close();
free(buf);
return 0;
} else { } else {
Syslog('+', "Can't lock msgbase %s", msgs.Base); if ((result = Msg_Open(CFG.dupboard)))
Msg_UnLock(); Syslog('+', "Tossing in dupe board");
Msg_Close();
return 1;
} }
} else {
result = Msg_Open(msgs.Base);
}
if (!result) {
WriteError("Can't open JAMmb %s", msgs.Base);
return 1;
}
if (Msg_Lock(30L)) {
if (dupe)
echo_dupe++;
else if (bad)
echo_bad++;
else
echo_imp++;
if (!do_quiet) {
mbse_colour(3, 0);
printf("\r%6u => %-40s\r", echo_in, msgs.Name);
fflush(stdout);
}
Msg_New();
/*
* Fill subfields
*/
strcpy(Msg.From, f->name);
strcpy(Msg.To, t->name);
strcpy(Msg.FromAddress, ascfnode(f,0x1f));
strcpy(Msg.Subject, subj);
Msg.Written = mdate;
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Echomail = TRUE;
/*
* These are the only usefull flags in echomail
*/
if ((flags & M_PVT) && ((msgs.MsgKinds == BOTH) || (msgs.MsgKinds == PRIVATE)))
Msg.Private = TRUE;
if (flags & M_FILE)
Msg.FileAttach = TRUE;
/*
* Set MSGID and REPLY crc.
*/
if (msgid != NULL) {
crc2 = -1;
Msg.MsgIdCRC = upd_crc32(msgid, crc2, strlen(msgid));
}
if (reply != NULL) {
crc2 = -1;
Msg.ReplyCRC = upd_crc32(reply, crc2, strlen(reply));
}
/*
* Start write the message
* If not a bad or dupe message, eat the first line (AREA:tag).
*/
buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
rewind(fp);
if (!dupe && !bad)
fgets(buf , MAX_LINE_LENGTH, fp);
Msg_Write(fp);
Msg_AddMsg();
Msg_UnLock();
Msg_Close();
free(buf);
return 0;
} else {
Syslog('+', "Can't lock msgbase %s", msgs.Base);
Msg_UnLock();
Msg_Close();
return 1;
}
} }

View File

@ -62,6 +62,8 @@ int storenet(faddr *f, faddr *t, time_t mdate, int flags, char *Subj, char *msgi
unsigned long crc2; unsigned long crc2;
char *Buf; char *Buf;
mbse_CleanSubject(Subj);
if (! SearchNetBoard(t->zone, t->net)) { if (! SearchNetBoard(t->zone, t->net)) {
bad = TRUE; bad = TRUE;
WriteError("Can't find netmail board for %d:%d/%d", t->zone, t->net, t->node); WriteError("Can't find netmail board for %d:%d/%d", t->zone, t->net, t->node);

View File

@ -676,6 +676,7 @@ void Reply_Email(int IsReply)
} else { } else {
sprintf(subj, "%s", Msg.Subject); sprintf(subj, "%s", Msg.Subject);
} }
mbse_CleanSubject(subj);
Syslog('m', "Reply msg to %s, subject %s", to, subj); Syslog('m', "Reply msg to %s, subject %s", to, subj);
Syslog('m', "Msgid was %s", Msg.Msgid); Syslog('m', "Msgid was %s", Msg.Msgid);
sprintf(msgid, "%s", Msg.Msgid); sprintf(msgid, "%s", Msg.Msgid);
@ -876,6 +877,7 @@ void Write_Email(void)
colour(CFG.MsgInputColourF, CFG.MsgInputColourB); colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
alarm_on(); alarm_on();
GetstrP(Msg.Subject, 65, 0); GetstrP(Msg.Subject, 65, 0);
mbse_CleanSubject(Msg.Subject);
if ((strcmp(Msg.Subject, "")) == 0) { if ((strcmp(Msg.Subject, "")) == 0) {
Enter(1); Enter(1);

View File

@ -566,6 +566,7 @@ void Post_Msg()
colour(CFG.MsgInputColourF, CFG.MsgInputColourB); colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
alarm_on(); alarm_on();
GetstrP(Msg.Subject, 65, 0); GetstrP(Msg.Subject, 65, 0);
mbse_CleanSubject(Msg.Subject);
if ((strcmp(Msg.Subject, "")) == 0) { if ((strcmp(Msg.Subject, "")) == 0) {
Enter(1); Enter(1);
@ -1642,6 +1643,7 @@ void Reply_Msg(int IsReply)
colour(CFG.MsgInputColourF, CFG.MsgInputColourB); colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrP(subj, 50, x); GetstrP(subj, 50, x);
mbse_CleanSubject(subj);
if (strlen(subj)) if (strlen(subj))
strcpy(Msg.Subject, subj); strcpy(Msg.Subject, subj);

View File

@ -1588,6 +1588,7 @@ void BlueWave_Fetch()
strcpy(Msg.From, Upr.from); strcpy(Msg.From, Upr.from);
strcpy(Msg.To, Upr.to); strcpy(Msg.To, Upr.to);
strcpy(Msg.Subject, Upr.subj); strcpy(Msg.Subject, Upr.subj);
mbse_CleanSubject(Msg.Subject);
if (Upr.msg_attr & UPL_PRIVATE) if (Upr.msg_attr & UPL_PRIVATE)
Msg.Private = TRUE; Msg.Private = TRUE;
if (msgs.MsgKinds == PRIVATE) if (msgs.MsgKinds == PRIVATE)

View File

@ -89,6 +89,7 @@ void retr_msg(int msgnum)
if (strlen(p) > 109) if (strlen(p) > 109)
p[109] = '\0'; p[109] = '\0';
sprintf(Msg.Subject, "%s", p+9); sprintf(Msg.Subject, "%s", p+9);
mbse_CleanSubject(Msg.Subject);
} }
if (strncmp(p, "Date: ", 6) == 0) if (strncmp(p, "Date: ", 6) == 0)
Msg.Written = parsedate(p+6, NULL) - (gmt_offset((time_t)0) * 60); Msg.Written = parsedate(p+6, NULL) - (gmt_offset((time_t)0) * 60);