From 54fdb57fad1fd81373607593f54c2ae8ed094170 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Tue, 16 Nov 2010 13:42:43 +0000 Subject: [PATCH] Fixed crash with '%' in attribute and 'Preset on reply = Re: $sttr' SVN revision: 2339 --- src/elogd.c | 82 ++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 996d0699..db8c7850 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -9355,11 +9355,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if ((!bedit && !breply && !bduplicate) || /* don't subst on edit or reply */ (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && strchr(preset, '#')) { /* get index */ @@ -9367,6 +9362,10 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); strcpy(attrib[index], preset); } } @@ -9376,11 +9375,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (orig_tag[0] == 0) { if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9388,8 +9382,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } } @@ -9399,11 +9396,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9411,8 +9403,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } @@ -9421,11 +9416,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9433,8 +9423,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } @@ -9463,11 +9456,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if ((!bedit && !breply && !bduplicate) || /* don't subst on edit or reply */ (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9475,8 +9463,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } @@ -9485,11 +9476,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9497,8 +9483,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } @@ -9507,11 +9496,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ - /* do not format date for date attributes */ - i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) - == 0); - strsubst_list(preset, sizeof(preset), slist, svalue, i); - /* check for index substitution */ if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { /* get index */ @@ -9519,8 +9503,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(preset, str); } - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + strcpy(attrib[index], preset); } } } @@ -22252,7 +22239,6 @@ void submit_elog(LOGBOOK * lbs) get_auto_index(lbs, i, subst_str, str, sizeof(str)); strcpy(subst_str, str); } - strcpy(attrib[i], subst_str); } }