From 14ecc81951270c7b5fe58fd245dec4ceb6d921b7 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 7 Dec 2016 18:30:47 +1000 Subject: [PATCH] Fix a bunch of quoteing bugs --- bbs.h | 2 +- email.c | 4 ++-- mail_menu.c | 10 +++++----- utils/magiedit/main.c | 17 +++++++++-------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/bbs.h b/bbs.h index caa81f0..464cfb8 100644 --- a/bbs.h +++ b/bbs.h @@ -211,7 +211,7 @@ extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct extern void mail_scan(struct user_record *user); extern int mail_menu(struct user_record *user); extern char *editor(struct user_record *user, char *quote, char *from, int email); -extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email); +extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email); extern int msg_is_to(struct user_record *user, char *addressed_to, char *address, int type, int rn, int msgconf); extern int msg_is_from(struct user_record *user, char *addressed_from, char *address, int type, int rn, int msgconf); extern unsigned long generate_msgid(); diff --git a/email.c b/email.c index d217b7c..45dcf27 100644 --- a/email.c +++ b/email.c @@ -59,7 +59,7 @@ void send_email(struct user_record *user) { subject = strdup(buffer); // post a message - msg = external_editor(user, user->loginname, recipient, NULL, NULL, subject, 1); + msg = external_editor(user, user->loginname, recipient, NULL, 0, NULL, subject, 1); if (msg != NULL) { sprintf(buffer, "%s/email.sq3", conf.bbs_path); @@ -276,7 +276,7 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema subject = (char *)malloc(strlen(buffer) + 1); strcpy(subject, buffer); - replybody = external_editor(user, user->loginname, emails[msgno]->from, emails[msgno]->body, emails[msgno]->from, subject, 1); + replybody = external_editor(user, user->loginname, emails[msgno]->from, emails[msgno]->body, strlen(emails[msgno]->body), emails[msgno]->from, subject, 1); if (replybody != NULL) { sprintf(buffer, "%s/email.sq3", conf.bbs_path); diff --git a/mail_menu.c b/mail_menu.c index d377346..efecc04 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -396,7 +396,7 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r return msghs; } -char *external_editor(struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email) { +char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email) { char c; FILE *fptr; char *body = NULL; @@ -432,7 +432,7 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot // write msgtemp if (quote != NULL) { fptr = fopen(buffer, "w"); - for (i=0;imsgs[mailno]->from, subject, 0); + replybody = external_editor(user, to, from, body, z2, msghs->msgs[mailno]->from, subject, 0); if (replybody != NULL) { jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); @@ -2096,7 +2096,7 @@ int mail_menu(struct user_record *user) { from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); sprintf(from, "%s %s", user->firstname, user->lastname); } - msg = external_editor(user, to, from, NULL, NULL, subject, 0); + msg = external_editor(user, to, from, NULL, 0, NULL, subject, 0); free(from); diff --git a/utils/magiedit/main.c b/utils/magiedit/main.c index d4f6430..f91691f 100644 --- a/utils/magiedit/main.c +++ b/utils/magiedit/main.c @@ -206,7 +206,7 @@ char *message_editor() { q_done = 0; q_marker = ' '; while (!q_done) { - for (i=q_start;i q_start + 20) { - q_start = q_start + 20; - if (q_start + 20 >= quote_line_count) { - q_start = quote_line_count - 20; + if (q_position >= q_start + 21) { + q_start = q_start + 21; + if (q_start + 21 >= quote_line_count) { + q_start = quote_line_count - 21; } } } @@ -310,6 +310,7 @@ char *message_editor() { } // restore screen + od_set_color(L_WHITE, D_BLACK); od_clr_scr(); od_set_cursor(1, 1); od_set_color(L_WHITE, D_BLUE); @@ -331,7 +332,7 @@ char *message_editor() { } od_clr_line(); } - + position_x = 0; memset(line, 0, 81); od_set_cursor(position_y + 3, position_x + 1); } else { @@ -707,7 +708,7 @@ int main(int argc, char **argv) if (!noquote) { fgets(buffer, 73, fptr); while (!feof(fptr)) { - for (i=strlen(buffer) - 1; i > 0; i--) { + for (i=strlen(buffer) - 1; i >= 0; i--) { if (buffer[i] != '\r' && buffer[i] != '\n') { break; } else {