From: Tristan Chabredier Date: Mon, 13 Nov 2006 09:36:09 +0000 (+0000) Subject: 2006-11-13 [wwp] 2.6.0cvs39 X-Git-Tag: rel_2_7_0~170 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=0ea9f238bb4e1af6207f90a22b8cc6046e898961 2006-11-13 [wwp] 2.6.0cvs39 * src/compose.c * src/quote_fmt_parse.y fix bug 1052: current parser buffer was not always allocated, ptr to this buffer could be returned as NULL whereas no parser error has occurred. in consequence, defining a template body as "%d" (w/o the quotes) for the first time of the instance of claws-mail, was reporting a parser error. make sure that the buffer is always allocated, even to an empty string. fix mis-unescaping in compose.:compose_quote_fmt(): unescaping of the fmt string was always done whereas it must be done *only* when receiving quote format strings issued from the prefs (compose new message, reply, forward, redirect formats), *not* when applying templates. in consequences, applying templates w/ sequences like \\|p{echo} were failing. make sure that unescaping is done only when necessary. --- diff --git a/ChangeLog b/ChangeLog index 2c5d76d4d..033d71e7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2006-11-13 [wwp] 2.6.0cvs39 + + * src/compose.c + * src/quote_fmt_parse.y + fix bug 1052: current parser buffer was not always allocated, ptr to this buffer could be + returned as NULL whereas no parser error has occurred. in consequence, defining a template + body as "%d" (w/o the quotes) for the first time of the instance of claws-mail, was reporting + a parser error. make sure that the buffer is always allocated, even to an empty string. + + fix mis-unescaping in compose.:compose_quote_fmt(): unescaping of the fmt string was always done + whereas it must be done *only* when receiving quote format strings issued from the prefs + (compose new message, reply, forward, redirect formats), *not* when applying templates. + in consequences, applying templates w/ sequences like \\|p{echo} were failing. make + sure that unescaping is done only when necessary. + 2006-11-12 [colin] 2.6.0cvs38 * po/de.po diff --git a/PATCHSETS b/PATCHSETS index 14542a9bf..d01cfc1ff 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2063,3 +2063,4 @@ ( cvs diff -u -r 1.1.2.34 -r 1.1.2.35 src/plugins/pgpcore/sgpgme.c; ) > 2.6.0cvs36.patchset ( cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/plugins/pgpinline/pgpinline.c; cvs diff -u -r 1.1.2.40 -r 1.1.2.41 src/plugins/pgpmime/pgpmime.c; ) > 2.6.0cvs37.patchset ( cvs diff -u -r 1.58.2.27 -r 1.58.2.28 po/de.po; ) > 2.6.0cvs38.patchset +( cvs diff -u -r 1.382.2.328 -r 1.382.2.329 src/compose.c; cvs diff -u -r 1.22.2.25 -r 1.22.2.26 src/quote_fmt_parse.y; ) > 2.6.0cvs39.patchset diff --git a/configure.ac b/configure.ac index a9a92484d..7f7fccd1f 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=6 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=38 +EXTRA_VERSION=39 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/compose.c b/src/compose.c index a1bbf41bc..4aaadc89c 100644 --- a/src/compose.c +++ b/src/compose.c @@ -223,6 +223,7 @@ static gchar *compose_quote_fmt (Compose *compose, const gchar *qmark, const gchar *body, gboolean rewrap, + gboolean need_unescape, const gchar *err_msg); static void compose_reply_set_entry (Compose *compose, @@ -1059,7 +1060,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI compose_quote_fmt(compose, dummyinfo, prefs_common.compose_body_format, - NULL, tmp, FALSE, + NULL, tmp, FALSE, TRUE, _("New message body format error.")); quote_fmt_reset_vartable(); @@ -1424,7 +1425,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote, compose_quote_fmt(compose, compose->replyinfo, prefs_common.quotefmt, - qmark, body, FALSE, + qmark, body, FALSE, TRUE, _("Message reply format error.")); quote_fmt_reset_vartable(); } @@ -1541,7 +1542,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, compose_quote_fmt(compose, full_msginfo, prefs_common.fw_quotefmt, - qmark, body, FALSE, + qmark, body, FALSE, TRUE, _("Message forward format error.")); quote_fmt_reset_vartable(); compose_attach_parts(compose, msginfo); @@ -2016,7 +2017,7 @@ Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo, msginfo->subject); gtk_editable_set_editable(GTK_EDITABLE(compose->subject_entry), FALSE); - compose_quote_fmt(compose, msginfo, "%M", NULL, NULL, FALSE, + compose_quote_fmt(compose, msginfo, "%M", NULL, NULL, FALSE, FALSE, _("Message redirect format error.")); quote_fmt_reset_vartable(); gtk_text_view_set_editable(GTK_TEXT_VIEW(compose->text), FALSE); @@ -2477,6 +2478,7 @@ static gchar *compose_parse_references(const gchar *ref, const gchar *msgid) static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, const gchar *fmt, const gchar *qmark, const gchar *body, gboolean rewrap, + gboolean need_unescape, const gchar *err_msg) { MsgInfo* dummyinfo = NULL; @@ -2511,20 +2513,25 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, } if (fmt && *fmt != '\0') { - gchar *tmp = NULL; if (trimmed_body) while (*trimmed_body == '\n') trimmed_body++; - /* decode \-escape sequences in the internal representation of the quote format */ - tmp = malloc(strlen(fmt)+1); - pref_get_unescaped_pref(tmp, fmt); - quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account); - quote_fmt_scan_string(tmp); - quote_fmt_parse(); - g_free(tmp); + if (need_unescape) { + gchar *tmp = NULL; + + /* decode \-escape sequences in the internal representation of the quote format */ + tmp = malloc(strlen(fmt)+1); + pref_get_unescaped_pref(tmp, fmt); + quote_fmt_scan_string(tmp); + quote_fmt_parse(); + g_free(tmp); + } else { + quote_fmt_scan_string(fmt); + quote_fmt_parse(); + } buf = quote_fmt_get_buffer(); if (buf == NULL) { @@ -6826,7 +6833,7 @@ static void compose_template_apply(Compose *compose, Template *tmpl, gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); parsed_str = compose_quote_fmt(compose, compose->replyinfo, - tmpl->value, qmark, NULL, FALSE, err_msg); + tmpl->value, qmark, NULL, FALSE, FALSE, err_msg); } else if (compose->fwdinfo != NULL) { @@ -6836,7 +6843,7 @@ static void compose_template_apply(Compose *compose, Template *tmpl, gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); parsed_str = compose_quote_fmt(compose, compose->fwdinfo, - tmpl->value, qmark, NULL, FALSE, err_msg); + tmpl->value, qmark, NULL, FALSE, FALSE, err_msg); } else { MsgInfo* dummyinfo = compose_msginfo_new_from_compose(compose); @@ -6853,7 +6860,7 @@ static void compose_template_apply(Compose *compose, Template *tmpl, gtk_text_buffer_set_text(buffer, "", -1); parsed_str = compose_quote_fmt(compose, dummyinfo, - tmpl->value, qmark, tmp, FALSE, err_msg); + tmpl->value, qmark, tmp, FALSE, FALSE, err_msg); procmsg_msginfo_free( dummyinfo ); g_free( tmp ); @@ -9088,7 +9095,7 @@ static void text_inserted(GtkTextBuffer *buffer, GtkTextIter *iter, mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE); gtk_text_buffer_place_cursor(buffer, iter); - compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE, + compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE, FALSE, _("Quote format error.")); quote_fmt_reset_vartable(); g_free(new_text); diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index d2107a48f..265aac601 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -116,6 +116,9 @@ static void clear_buffer(void) { if (current->buffer) *current->buffer = '\0'; + else + /* force to an empty string, as buffer should not be left unallocated */ + add_buffer(""); current->bufsize = 0; }