From 7f7c9e1bb4dd4f801d9cda59516b0569175b26e6 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Thu, 19 Nov 2009 01:25:32 +0000 Subject: [PATCH] Avoid double substitutions on 'preset on reply' SVN revision: 2270 --- src/elogd.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index af7b07ad..fb36ae6f 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -9319,20 +9319,31 @@ 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 multiple substitution */ + strlcpy(str, preset, sizeof(str)); + if (strchr(str, '$')) + *strchr(str, '$') = 0; + if (strchr(str, '%')) + *strchr(str, '%') = 0; + if (strchr(str, '#')) + *strchr(str, '#') = 0; + if (strncmp(str, attrib[index], strlen(str)) != 0) { - /* check for index substitution */ - if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { - /* get index */ - get_auto_index(lbs, index, preset, str, sizeof(str)); - 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); + + /* check for index substitution */ + if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { + /* get index */ + get_auto_index(lbs, index, preset, str, sizeof(str)); + strcpy(preset, str); + } + + if (!strchr(preset, '%')) + strcpy(attrib[index], preset); } - - if (!strchr(preset, '%')) - strcpy(attrib[index], preset); } }