2006-11-13 [wwp] 2.6.0cvs39
authorTristan Chabredier <wwp@claws-mail.org>
Mon, 13 Nov 2006 09:36:09 +0000 (09:36 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Mon, 13 Nov 2006 09:36:09 +0000 (09:36 +0000)
* 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.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/quote_fmt_parse.y

index 2c5d76d4d90db525c720b8a91b98ed0ab26d5e6c..033d71e7d5f91ec6e14464d6c7db8ff238bb5b1f 100644 (file)
--- 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
 2006-11-12 [colin]     2.6.0cvs38
 
        * po/de.po
index 14542a9bf16c31910bd98740ed48892cc671eb71..d01cfc1ff1ec14c37e2282d35f49b4dc4ae9b61f 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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.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
index a9a92484dccd6dacea90ff60b4b7788fa9e0ebfd..7f7fccd1f47685b06c906844bf6d18f372060428 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=38
+EXTRA_VERSION=39
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index a1bbf41bc232ab79f392c002d56717d34ff3af45..4aaadc89c778ed8824413837103f9528a0e4f778 100644 (file)
@@ -223,6 +223,7 @@ static gchar *compose_quote_fmt                     (Compose        *compose,
                                                 const gchar    *qmark,
                                                 const gchar    *body,
                                                 gboolean        rewrap,
                                                 const gchar    *qmark,
                                                 const gchar    *body,
                                                 gboolean        rewrap,
+                                                gboolean        need_unescape,
                                                 const gchar *err_msg);
 
 static void compose_reply_set_entry            (Compose        *compose,
                                                 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,
 
                        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();
 
                                                  _("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,
 
                compose_quote_fmt(compose, compose->replyinfo,
                                  prefs_common.quotefmt,
-                                 qmark, body, FALSE,
+                                 qmark, body, FALSE, TRUE,
                                          _("Message reply format error."));
                quote_fmt_reset_vartable();
        }
                                          _("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,
 
                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);
                                          _("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);
 
                                   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);
                                          _("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,
 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;
                                const gchar *err_msg)
 {
        MsgInfo* dummyinfo = NULL;
@@ -2511,20 +2513,25 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
        }
 
        if (fmt && *fmt != '\0') {
        }
 
        if (fmt && *fmt != '\0') {
-               gchar *tmp = NULL;
 
                if (trimmed_body)
                        while (*trimmed_body == '\n')
                                trimmed_body++;
 
 
                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_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) {
 
                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,
                        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) {
 
 
                } 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,
                        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);
 
                } 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,
                                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 );
                        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);
 
                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);
                                                  _("Quote format error."));
                quote_fmt_reset_vartable();
                g_free(new_text);
index d2107a48f52b67f0a956c86ecab659c7ad504789..265aac601e071076fb061837e5c0e6d86d558b01 100644 (file)
@@ -116,6 +116,9 @@ static void clear_buffer(void)
 {
        if (current->buffer)
                *current->buffer = '\0';
 {
        if (current->buffer)
                *current->buffer = '\0';
+       else
+               /* force to an empty string, as buffer should not be left unallocated */
+               add_buffer("");
        current->bufsize = 0;
 }
 
        current->bufsize = 0;
 }