* [PATCH 0/6] Clean up reply's encoding story
@ 2013-08-12 18:40 Austin Clements
2013-08-12 18:40 ` [PATCH 1/6] lib: Correct out-of-date doc comment Austin Clements
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
Jeff Stedfast's email about gmime-filter-headers.c possibly being
unnecessary with GMime 2.6 (quoted in id:87bo56viyo.fsf@nikula.org)
sent me on a wild goose chase that led to this patch series. It
turned out that we *did* need gmime-filter-headers for what we were
doing in the reply text format, but what we were doing made no sense.
Patches 1 through 4 are simply the documentation and tests that I left
in my wake and are harmless to push. Patch 6 is my conclusion that
how we were handling header encoding in the text reply format made no
sense. Patch 5 is a step toward patch 6, but makes sense on its own
even if we decide against patch 6.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] lib: Correct out-of-date doc comment
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-12 18:40 ` [PATCH 2/6] lib: Document which strings are returned in UTF-8 Austin Clements
` (5 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
notmuch_message_get_header started returning some headers straight
from the database in 567bcbc, but this comment explicitly claimed all
headers were read from the message file.
---
lib/notmuch.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 73c85a4..9fc34ef 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1015,8 +1015,11 @@ notmuch_message_get_date (notmuch_message_t *message);
/* Get the value of the specified header from 'message'.
*
- * The value will be read from the actual message file, not from the
- * notmuch database. The header name is case insensitive.
+ * Common headers are stored in the database when the message is
+ * indexed and will be returned from the database. Other headers will
+ * be read from the actual message file.
+ *
+ * The header name is case insensitive.
*
* The returned string belongs to the message so should not be
* modified or freed by the caller (nor should it be referenced after
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] lib: Document which strings are returned in UTF-8
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
2013-08-12 18:40 ` [PATCH 1/6] lib: Correct out-of-date doc comment Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-12 18:40 ` [PATCH 3/6] reply: Document the reason for g_mime_filter_headers Austin Clements
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
Any string that ultimately comes from notmuch_message_file_get_header
is in UTF-8.
---
lib/notmuch-private.h | 2 +-
lib/notmuch.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index cc55bb9..eced03e 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -386,7 +386,7 @@ void
notmuch_message_file_restrict_headersv (notmuch_message_file_t *message,
va_list va_headers);
-/* Get the value of the specified header from the message.
+/* Get the value of the specified header from the message as a UTF-8 string.
*
* The header name is case insensitive.
*
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 9fc34ef..998a4ae 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -767,7 +767,7 @@ notmuch_thread_get_messages (notmuch_thread_t *thread);
int
notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
-/* Get the authors of 'thread'
+/* Get the authors of 'thread' as a UTF-8 string.
*
* The returned string is a comma-separated list of the names of the
* authors of mail messages in the query results that belong to this
@@ -781,7 +781,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
const char *
notmuch_thread_get_authors (notmuch_thread_t *thread);
-/* Get the subject of 'thread'
+/* Get the subject of 'thread' as a UTF-8 string.
*
* The subject is taken from the first message (according to the query
* order---see notmuch_query_set_sort) in the query results that
@@ -1013,7 +1013,7 @@ notmuch_message_set_flag (notmuch_message_t *message,
time_t
notmuch_message_get_date (notmuch_message_t *message);
-/* Get the value of the specified header from 'message'.
+/* Get the value of the specified header from 'message' as a UTF-8 string.
*
* Common headers are stored in the database when the message is
* indexed and will be returned from the database. Other headers will
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] reply: Document the reason for g_mime_filter_headers
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
2013-08-12 18:40 ` [PATCH 1/6] lib: Correct out-of-date doc comment Austin Clements
2013-08-12 18:40 ` [PATCH 2/6] lib: Document which strings are returned in UTF-8 Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-15 8:40 ` David Bremner
2013-08-12 18:40 ` [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers Austin Clements
` (3 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
Given how long it took me to figure out why we pass the reply headers
through g_mime_filter_headers, it's worth a comment.
---
notmuch-reply.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/notmuch-reply.c b/notmuch-reply.c
index e151f78..3b2b58d 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -34,6 +34,10 @@ show_reply_headers (GMimeMessage *message)
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
stream_filter = g_mime_stream_filter_new(stream_stdout);
if (stream_filter) {
+ // g_mime_object_write_to_stream will produce
+ // RFC2047-encoded headers, but we want to present the
+ // user with decoded headers and let whatever
+ // ultimately sends the mail do the RFC2047 encoding.
g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
g_mime_filter_headers_new());
g_mime_object_write_to_stream(GMIME_OBJECT(message), stream_filter);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
` (2 preceding siblings ...)
2013-08-12 18:40 ` [PATCH 3/6] reply: Document the reason for g_mime_filter_headers Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-13 16:13 ` Austin Clements
2013-08-12 18:40 ` [PATCH 5/6] reply: Remove extraneous space from generated References Austin Clements
` (2 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
---
test/reply | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/test/reply b/test/reply
index ee5d361..a85ebe5 100755
--- a/test/reply
+++ b/test/reply
@@ -193,4 +193,60 @@ References: <${gen_msg_id}>
On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
> From guessing"
+test_begin_subtest "Reply with RFC 2047-encoded headers"
+add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
+ '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
+ '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
+ '[body]="Encoding"'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal "$output" "\
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+Subject: Re: àßç
+To: ☃ <snowman@example.com>
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
+> Encoding"
+
+test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
+output=$(notmuch reply --format=json id:${gen_msg_id})
+test_expect_equal_json "$output" '
+{
+ "original": {
+ "body": [
+ {
+ "content": "Encoding\n",
+ "content-type": "text/plain",
+ "id": 1
+ }
+ ],
+ "date_relative": "2010-01-05",
+ "excluded": false,
+ "filename": "'${MAIL_DIR}'/msg-012",
+ "headers": {
+ "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
+ "From": "\u2603 <snowman@example.com>",
+ "Subject": "\u00e0\u00df\u00e7",
+ "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
+ },
+ "id": "'${gen_msg_id}'",
+ "match": false,
+ "tags": [
+ "inbox",
+ "unread"
+ ],
+ "timestamp": 1262706236
+ },
+ "reply-headers": {
+ "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
+ "In-reply-to": "<'${gen_msg_id}'>",
+ "References": "<'${gen_msg_id}'>",
+ "Subject": "Re: \u00e0\u00df\u00e7",
+ "To": "\u2603 <snowman@example.com>"
+ }
+}'
+
+
test_done
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] reply: Remove extraneous space from generated References
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
` (3 preceding siblings ...)
2013-08-12 18:40 ` [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-12 18:40 ` [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template Austin Clements
2013-08-14 17:04 ` [PATCH 0/6] Clean up reply's encoding story Tomi Ollila
6 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
Previously, the References header code seemed to assume
notmuch_message_get_header would return NULL if the header was not
present, but it actually returns "". As a result of this, it was
inserting an unnecessary space when concatenating an empty or missing
original references header with the new reference.
This shows up in only one test because the text reply format later
passes the whole reply template through g_mime_filter_headers, which
has the side effect of stripping out this extra space.
---
notmuch-reply.c | 14 ++++++++------
test/multipart | 2 +-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3b2b58d..0f3b9cd 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -537,12 +537,14 @@ create_reply_message(void *ctx,
"In-Reply-To", in_reply_to);
orig_references = notmuch_message_get_header (message, "references");
- references = talloc_asprintf (ctx, "%s%s%s",
- orig_references ? orig_references : "",
- orig_references ? " " : "",
- in_reply_to);
- g_mime_object_set_header (GMIME_OBJECT (reply),
- "References", references);
+ if (orig_references) {
+ references = talloc_asprintf (ctx, "%s%s%s",
+ *orig_references ? orig_references : "",
+ *orig_references ? " " : "",
+ in_reply_to);
+ g_mime_object_set_header (GMIME_OBJECT (reply),
+ "References", references);
+ }
return reply;
}
diff --git a/test/multipart b/test/multipart
index c974226..2033023 100755
--- a/test/multipart
+++ b/test/multipart
@@ -599,7 +599,7 @@ cat <<EOF >EXPECTED
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
"In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
- "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},
+ "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},
"original": {"id": "XXXXX",
"match": false,
"excluded": false,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
` (4 preceding siblings ...)
2013-08-12 18:40 ` [PATCH 5/6] reply: Remove extraneous space from generated References Austin Clements
@ 2013-08-12 18:40 ` Austin Clements
2013-08-12 20:01 ` Austin Clements
2013-08-14 17:04 ` [PATCH 0/6] Clean up reply's encoding story Tomi Ollila
6 siblings, 1 reply; 12+ messages in thread
From: Austin Clements @ 2013-08-12 18:40 UTC (permalink / raw)
To: notmuch
Previously, reply's default text format used an odd mix of RFC 2045
MIME encoding for the reply template's body and some made-up RFC
2822-like UTF-8 format for the headers. The intent was to present the
headers to the user in a nice, un-encoded format, but this assumed
that whatever ultimately sent the email would RFC 2047-encode the
headers, while at the same time the body was already RFC 2045 encoded,
so it assumed that whatever sent the email would *not* re-encode the
body.
This can be fixed by either producing a fully decoded UTF-8 reply
template, or a fully encoded MIME-compliant RFC 2822 message. This
patch does the latter because it is
a) Well-defined by RFC 2822 and MIME (while any UTF-8 format would be
ad hoc).
b) Ready to be piped to sendmail. The point of the text format is to
be minimal, so a user should be able to pop up the tmeplate in
whatever editor they want, edit it, and push it to sendmail.
c) Consistent with how frontend capabilities. If a frontend has the
smarts to RFC 2047 encode the headers before sending the mail, it
probably has the smarts to RFC 2047 decode them before presenting
the template to a user for editing.
Also, as far as I know, nothing automated consumes the reply text
format, so changing this should not cause serious problems. (And if
anything does still consume this format, it probably gets these
encoding issues wrong anyway.)
---
Makefile.local | 1 -
| 263 ----------------------------------------------
| 69 ------------
man/man1/notmuch-reply.1 | 2 +-
notmuch-reply.c | 15 +--
test/reply | 9 +-
test/reply-to-sender | 4 +-
7 files changed, 12 insertions(+), 351 deletions(-)
delete mode 100644 gmime-filter-headers.c
delete mode 100644 gmime-filter-headers.h
diff --git a/Makefile.local b/Makefile.local
index 84043fe..b7cd266 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -255,7 +255,6 @@ notmuch_client_srcs = \
command-line-arguments.c\
debugger.c \
gmime-filter-reply.c \
- gmime-filter-headers.c \
hooks.c \
notmuch.c \
notmuch-config.c \
diff --git a/gmime-filter-headers.c b/gmime-filter-headers.c
deleted file mode 100644
index 7db3779..0000000
--- a/gmime-filter-headers.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright © 2009 Keith Packard <keithp@keithp.com>
- * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "gmime-filter-headers.h"
-#include <string.h>
-#include <gmime/gmime-utils.h>
-#include <glib/gprintf.h>
-#include <stdlib.h>
-#include <xutil.h>
-
-/**
- * SECTION: gmime-filter-headers
- * @title: GMimeFilterHeaders
- * @short_description: Add/remove headers markers
- *
- * A #GMimeFilter for decoding rfc2047 encoded headers to UTF-8
- **/
-
-
-static void g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass);
-static void g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass);
-static void g_mime_filter_headers_finalize (GObject *object);
-
-static GMimeFilter *filter_copy (GMimeFilter *filter);
-static void filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
- char **out, size_t *outlen, size_t *outprespace);
-static void filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
- char **out, size_t *outlen, size_t *outprespace);
-static void filter_reset (GMimeFilter *filter);
-
-
-static GMimeFilterClass *parent_class = NULL;
-
-GType
-g_mime_filter_headers_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (GMimeFilterHeadersClass),
- NULL, /* base_class_init */
- NULL, /* base_class_finalize */
- (GClassInitFunc) g_mime_filter_headers_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GMimeFilterHeaders),
- 0, /* n_preallocs */
- (GInstanceInitFunc) g_mime_filter_headers_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterHeaders", &info, (GTypeFlags) 0);
- }
-
- return type;
-}
-
-
-static void
-g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
-
- parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
-
- object_class->finalize = g_mime_filter_headers_finalize;
-
- filter_class->copy = filter_copy;
- filter_class->filter = filter_filter;
- filter_class->complete = filter_complete;
- filter_class->reset = filter_reset;
-}
-
-static void
-g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass)
-{
- (void) klass;
- filter->saw_nl = TRUE;
- filter->line = NULL;
- filter->line_size = 0;
- filter->lineptr = NULL;
-}
-
-static void
-g_mime_filter_headers_finalize (GObject *object)
-{
- free (GMIME_FILTER_HEADERS (object)->line);
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static GMimeFilter *
-filter_copy (GMimeFilter *filter)
-{
- (void) filter;
- return g_mime_filter_headers_new ();
-}
-
-static void
-output_decoded_header (GMimeFilterHeaders *headers, char **outptr)
-{
- char *colon, *name, *s, *decoded_value;
- size_t offset;
- gint ret;
-
- colon = strchr (headers->line, ':');
- if (colon == NULL)
- return;
-
- name = headers->line;
- *colon = '\0';
- s = colon + 1;
- while (*s == ' ' || *s == '\t')
- s++;
- decoded_value = g_mime_utils_header_decode_text(s);
- if (decoded_value == NULL)
- return;
- offset = *outptr - GMIME_FILTER (headers)->outbuf;
- g_mime_filter_set_size (GMIME_FILTER (headers), strlen(name) + 2 +
- strlen(decoded_value) + 2, TRUE);
- *outptr = GMIME_FILTER (headers)->outbuf + offset;
- ret = g_sprintf (*outptr, "%s: %s\n", name, decoded_value);
- if (ret > 0)
- *outptr += ret;
- free (decoded_value);
-}
-
-static void
-output_final_newline (GMimeFilterHeaders *headers, char **outptr)
-{
- size_t offset;
-
- offset = *outptr - GMIME_FILTER (headers)->outbuf;
- g_mime_filter_set_size (GMIME_FILTER (headers), 1, TRUE);
- *outptr = GMIME_FILTER (headers)->outbuf + offset;
- *(*outptr)++ = '\n';
-}
-
-static void
-filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
- char **outbuf, size_t *outlen, size_t *outprespace)
-{
- GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;
- register const char *inptr = inbuf;
- const char *inend = inbuf + inlen;
- char *lineptr, *lineend, *outptr;
-
- (void) prespace;
- if (headers->line == NULL) {
- headers->line_size = 200;
- headers->lineptr = headers->line = malloc (headers->line_size);
- }
- lineptr = headers->lineptr;
- lineend = headers->line + headers->line_size - 1;
- if (lineptr == NULL)
- return;
- outptr = filter->outbuf;
- while (inptr < inend) {
- if (*inptr == '\n') {
- if (headers->saw_nl)
- output_final_newline(headers, &outptr);
- headers->saw_nl = TRUE;
- inptr++;
- continue;
- }
-
- if (lineptr == lineend) {
- headers->line_size *= 2;
- headers->line = xrealloc (headers->line, headers->line_size);
- lineptr = headers->line + (headers->line_size / 2) - 1;
- lineend = headers->line + headers->line_size - 1;
- }
-
- if (headers->saw_nl && *inptr != ' ' && *inptr != '\t') {
- *lineptr = '\0';
- output_decoded_header (headers, &outptr);
- lineptr = headers->line;
- }
- if (headers->saw_nl && (*inptr == ' ' || *inptr == '\t')) {
- *lineptr = ' ';
- lineptr++;
- while (inptr < inend && (*inptr == ' ' || *inptr == '\t'))
- inptr++;
- headers->saw_nl = FALSE;
- continue;
- }
- headers->saw_nl = FALSE;
-
- if (*inptr != '\r')
- *lineptr++ = *inptr;
- inptr++;
- }
- if (headers->saw_nl) {
- *lineptr = '\0';
- output_decoded_header (headers, &outptr);
- lineptr = headers->line;
- }
- headers->lineptr = lineptr;
- *outlen = outptr - filter->outbuf;
- *outprespace = filter->outpre;
- *outbuf = filter->outbuf;
-}
-
-static void
-filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
- char **outbuf, size_t *outlen, size_t *outprespace)
-{
- if (inbuf && inlen)
- filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
-}
-
-static void
-filter_reset (GMimeFilter *filter)
-{
- GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;
-
- headers->saw_nl = TRUE;
- free(headers->line);
- headers->line = NULL;
- headers->line_size = 0;
-}
-
-
-/**
- * g_mime_filter_headers_new:
- * @encode: %TRUE if the filter should encode or %FALSE otherwise
- * @dots: encode/decode dots (as for SMTP)
- *
- * Creates a new #GMimeFilterHeaders filter.
- *
- * If @encode is %TRUE, then all lines will be prefixed by "> ",
- * otherwise any lines starting with "> " will have that removed
- *
- * Returns: a new #GMimeFilterHeaders filter.
- **/
-GMimeFilter *
-g_mime_filter_headers_new (void)
-{
- GMimeFilterHeaders *new_headers;
-
- new_headers = (GMimeFilterHeaders *) g_object_newv (GMIME_TYPE_FILTER_HEADERS, 0, NULL);
-
- return (GMimeFilter *) new_headers;
-}
-
diff --git a/gmime-filter-headers.h b/gmime-filter-headers.h
deleted file mode 100644
index 1d1a3eb..0000000
--- a/gmime-filter-headers.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 2009 Keith Packard <keithp@keithp.com>
- * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#ifndef _GMIME_FILTER_HEADERS_H_
-#define _GMIME_FILTER_HEADERS_H_
-
-#include <gmime/gmime-filter.h>
-
-G_BEGIN_DECLS
-
-#define GMIME_TYPE_FILTER_HEADERS (g_mime_filter_headers_get_type ())
-#define GMIME_FILTER_HEADERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeaders))
-#define GMIME_FILTER_HEADERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))
-#define GMIME_IS_FILTER_HEADERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER_HEADERS))
-#define GMIME_IS_FILTER_HEADERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER_HEADERS))
-#define GMIME_FILTER_HEADERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))
-
-typedef struct _GMimeFilterHeaders GMimeFilterHeaders;
-typedef struct _GMimeFilterHeadersClass GMimeFilterHeadersClass;
-
-/**
- * GMimeFilterHeaders:
- * @parent_object: parent #GMimeFilter
- * @saw_nl: previous char was a \n
- * @line: temporary buffer for line unfolding
- * @line_size: size of currently allocated memory for @line
- * @lineptr: pointer to the first unused character in @line
- *
- * A filter to decode rfc2047 encoded headers
- **/
-struct _GMimeFilterHeaders {
- GMimeFilter parent_object;
-
- gboolean saw_nl;
- char *line;
- size_t line_size;
- char *lineptr;
-};
-
-struct _GMimeFilterHeadersClass {
- GMimeFilterClass parent_class;
-
-};
-
-
-GType g_mime_filter_headers_get_type (void);
-
-GMimeFilter *g_mime_filter_headers_new (void);
-
-G_END_DECLS
-
-
-#endif /* _GMIME_FILTER_HEADERS_H_ */
diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
index ac76b07..e553145 100644
--- a/man/man1/notmuch-reply.1
+++ b/man/man1/notmuch-reply.1
@@ -41,7 +41,7 @@ include
.RS
.TP 4
.BR default
-Includes subject and quoted message body.
+Includes subject and quoted message body as an RFC 2822 message.
.TP
.BR json
Produces JSON output containing headers for a reply message and the
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 0f3b9cd..bfd0f51 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -21,28 +21,17 @@
*/
#include "notmuch-client.h"
-#include "gmime-filter-headers.h"
#include "sprinter.h"
static void
show_reply_headers (GMimeMessage *message)
{
- GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
+ GMimeStream *stream_stdout = NULL;
stream_stdout = g_mime_stream_file_new (stdout);
if (stream_stdout) {
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
- stream_filter = g_mime_stream_filter_new(stream_stdout);
- if (stream_filter) {
- // g_mime_object_write_to_stream will produce
- // RFC2047-encoded headers, but we want to present the
- // user with decoded headers and let whatever
- // ultimately sends the mail do the RFC2047 encoding.
- g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
- g_mime_filter_headers_new());
- g_mime_object_write_to_stream(GMIME_OBJECT(message), stream_filter);
- g_object_unref(stream_filter);
- }
+ g_mime_object_write_to_stream (GMIME_OBJECT(message), stream_stdout);
g_object_unref(stream_stdout);
}
}
diff --git a/test/reply b/test/reply
index a85ebe5..d4389cf 100755
--- a/test/reply
+++ b/test/reply
@@ -132,7 +132,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than
'[body]="200-byte header"'
output=$(notmuch reply id:${gen_msg_id})
test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
-Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces
+Subject: Re: This subject is exactly 200 bytes in length. Other than its
+ length there is not much of note here. Note that the length of 200 bytes
+ includes the Subject: and Re: prefixes with two spaces
In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}>
@@ -200,10 +202,11 @@ add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
'[body]="Encoding"'
output=$(notmuch reply id:${gen_msg_id})
+# Note that GMime changes from Q- to B-encoding
test_expect_equal "$output" "\
From: Notmuch Test Suite <test_suite@notmuchmail.org>
-Subject: Re: àßç
-To: ☃ <snowman@example.com>
+Subject: Re: =?iso-8859-1?b?4N/n?=
+To: =?UTF-8?b?4piD?= <snowman@example.com>
In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}>
diff --git a/test/reply-to-sender b/test/reply-to-sender
index c7d15bb..30e5e38 100755
--- a/test/reply-to-sender
+++ b/test/reply-to-sender
@@ -200,7 +200,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than
'[body]="200-byte header"'
output=$(notmuch reply --reply-to=sender id:${gen_msg_id})
test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
-Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces
+Subject: Re: This subject is exactly 200 bytes in length. Other than its
+ length there is not much of note here. Note that the length of 200 bytes
+ includes the Subject: and Re: prefixes with two spaces
In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}>
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template
2013-08-12 18:40 ` [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template Austin Clements
@ 2013-08-12 20:01 ` Austin Clements
0 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-12 20:01 UTC (permalink / raw)
To: notmuch
Quoth myself on Aug 12 at 2:40 pm:
> Previously, reply's default text format used an odd mix of RFC 2045
> MIME encoding for the reply template's body and some made-up RFC
> 2822-like UTF-8 format for the headers. The intent was to present the
> headers to the user in a nice, un-encoded format, but this assumed
> that whatever ultimately sent the email would RFC 2047-encode the
> headers, while at the same time the body was already RFC 2045 encoded,
> so it assumed that whatever sent the email would *not* re-encode the
> body.
>
> This can be fixed by either producing a fully decoded UTF-8 reply
> template, or a fully encoded MIME-compliant RFC 2822 message. This
> patch does the latter because it is
>
> a) Well-defined by RFC 2822 and MIME (while any UTF-8 format would be
> ad hoc).
>
> b) Ready to be piped to sendmail. The point of the text format is to
> be minimal, so a user should be able to pop up the tmeplate in
> whatever editor they want, edit it, and push it to sendmail.
>
> c) Consistent with how frontend capabilities. If a frontend has the
This was supposed to be "Consistent with frontend capabilities." of
course.
> smarts to RFC 2047 encode the headers before sending the mail, it
> probably has the smarts to RFC 2047 decode them before presenting
> the template to a user for editing.
>
> Also, as far as I know, nothing automated consumes the reply text
> format, so changing this should not cause serious problems. (And if
> anything does still consume this format, it probably gets these
> encoding issues wrong anyway.)
> ---
> Makefile.local | 1 -
> gmime-filter-headers.c | 263 ----------------------------------------------
> gmime-filter-headers.h | 69 ------------
> man/man1/notmuch-reply.1 | 2 +-
> notmuch-reply.c | 15 +--
> test/reply | 9 +-
> test/reply-to-sender | 4 +-
> 7 files changed, 12 insertions(+), 351 deletions(-)
> delete mode 100644 gmime-filter-headers.c
> delete mode 100644 gmime-filter-headers.h
>
> diff --git a/Makefile.local b/Makefile.local
> index 84043fe..b7cd266 100644
> --- a/Makefile.local
> +++ b/Makefile.local
> @@ -255,7 +255,6 @@ notmuch_client_srcs = \
> command-line-arguments.c\
> debugger.c \
> gmime-filter-reply.c \
> - gmime-filter-headers.c \
> hooks.c \
> notmuch.c \
> notmuch-config.c \
> diff --git a/gmime-filter-headers.c b/gmime-filter-headers.c
> deleted file mode 100644
> index 7db3779..0000000
> --- a/gmime-filter-headers.c
> +++ /dev/null
> @@ -1,263 +0,0 @@
> -/*
> - * Copyright © 2009 Keith Packard <keithp@keithp.com>
> - * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation, either version 3 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write to the Free Software Foundation, Inc.,
> - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> - */
> -
> -#include "gmime-filter-headers.h"
> -#include <string.h>
> -#include <gmime/gmime-utils.h>
> -#include <glib/gprintf.h>
> -#include <stdlib.h>
> -#include <xutil.h>
> -
> -/**
> - * SECTION: gmime-filter-headers
> - * @title: GMimeFilterHeaders
> - * @short_description: Add/remove headers markers
> - *
> - * A #GMimeFilter for decoding rfc2047 encoded headers to UTF-8
> - **/
> -
> -
> -static void g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass);
> -static void g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass);
> -static void g_mime_filter_headers_finalize (GObject *object);
> -
> -static GMimeFilter *filter_copy (GMimeFilter *filter);
> -static void filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
> - char **out, size_t *outlen, size_t *outprespace);
> -static void filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
> - char **out, size_t *outlen, size_t *outprespace);
> -static void filter_reset (GMimeFilter *filter);
> -
> -
> -static GMimeFilterClass *parent_class = NULL;
> -
> -GType
> -g_mime_filter_headers_get_type (void)
> -{
> - static GType type = 0;
> -
> - if (!type) {
> - static const GTypeInfo info = {
> - sizeof (GMimeFilterHeadersClass),
> - NULL, /* base_class_init */
> - NULL, /* base_class_finalize */
> - (GClassInitFunc) g_mime_filter_headers_class_init,
> - NULL, /* class_finalize */
> - NULL, /* class_data */
> - sizeof (GMimeFilterHeaders),
> - 0, /* n_preallocs */
> - (GInstanceInitFunc) g_mime_filter_headers_init,
> - NULL /* value_table */
> - };
> -
> - type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterHeaders", &info, (GTypeFlags) 0);
> - }
> -
> - return type;
> -}
> -
> -
> -static void
> -g_mime_filter_headers_class_init (GMimeFilterHeadersClass *klass)
> -{
> - GObjectClass *object_class = G_OBJECT_CLASS (klass);
> - GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
> -
> - parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
> -
> - object_class->finalize = g_mime_filter_headers_finalize;
> -
> - filter_class->copy = filter_copy;
> - filter_class->filter = filter_filter;
> - filter_class->complete = filter_complete;
> - filter_class->reset = filter_reset;
> -}
> -
> -static void
> -g_mime_filter_headers_init (GMimeFilterHeaders *filter, GMimeFilterHeadersClass *klass)
> -{
> - (void) klass;
> - filter->saw_nl = TRUE;
> - filter->line = NULL;
> - filter->line_size = 0;
> - filter->lineptr = NULL;
> -}
> -
> -static void
> -g_mime_filter_headers_finalize (GObject *object)
> -{
> - free (GMIME_FILTER_HEADERS (object)->line);
> - G_OBJECT_CLASS (parent_class)->finalize (object);
> -}
> -
> -
> -static GMimeFilter *
> -filter_copy (GMimeFilter *filter)
> -{
> - (void) filter;
> - return g_mime_filter_headers_new ();
> -}
> -
> -static void
> -output_decoded_header (GMimeFilterHeaders *headers, char **outptr)
> -{
> - char *colon, *name, *s, *decoded_value;
> - size_t offset;
> - gint ret;
> -
> - colon = strchr (headers->line, ':');
> - if (colon == NULL)
> - return;
> -
> - name = headers->line;
> - *colon = '\0';
> - s = colon + 1;
> - while (*s == ' ' || *s == '\t')
> - s++;
> - decoded_value = g_mime_utils_header_decode_text(s);
> - if (decoded_value == NULL)
> - return;
> - offset = *outptr - GMIME_FILTER (headers)->outbuf;
> - g_mime_filter_set_size (GMIME_FILTER (headers), strlen(name) + 2 +
> - strlen(decoded_value) + 2, TRUE);
> - *outptr = GMIME_FILTER (headers)->outbuf + offset;
> - ret = g_sprintf (*outptr, "%s: %s\n", name, decoded_value);
> - if (ret > 0)
> - *outptr += ret;
> - free (decoded_value);
> -}
> -
> -static void
> -output_final_newline (GMimeFilterHeaders *headers, char **outptr)
> -{
> - size_t offset;
> -
> - offset = *outptr - GMIME_FILTER (headers)->outbuf;
> - g_mime_filter_set_size (GMIME_FILTER (headers), 1, TRUE);
> - *outptr = GMIME_FILTER (headers)->outbuf + offset;
> - *(*outptr)++ = '\n';
> -}
> -
> -static void
> -filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
> - char **outbuf, size_t *outlen, size_t *outprespace)
> -{
> - GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;
> - register const char *inptr = inbuf;
> - const char *inend = inbuf + inlen;
> - char *lineptr, *lineend, *outptr;
> -
> - (void) prespace;
> - if (headers->line == NULL) {
> - headers->line_size = 200;
> - headers->lineptr = headers->line = malloc (headers->line_size);
> - }
> - lineptr = headers->lineptr;
> - lineend = headers->line + headers->line_size - 1;
> - if (lineptr == NULL)
> - return;
> - outptr = filter->outbuf;
> - while (inptr < inend) {
> - if (*inptr == '\n') {
> - if (headers->saw_nl)
> - output_final_newline(headers, &outptr);
> - headers->saw_nl = TRUE;
> - inptr++;
> - continue;
> - }
> -
> - if (lineptr == lineend) {
> - headers->line_size *= 2;
> - headers->line = xrealloc (headers->line, headers->line_size);
> - lineptr = headers->line + (headers->line_size / 2) - 1;
> - lineend = headers->line + headers->line_size - 1;
> - }
> -
> - if (headers->saw_nl && *inptr != ' ' && *inptr != '\t') {
> - *lineptr = '\0';
> - output_decoded_header (headers, &outptr);
> - lineptr = headers->line;
> - }
> - if (headers->saw_nl && (*inptr == ' ' || *inptr == '\t')) {
> - *lineptr = ' ';
> - lineptr++;
> - while (inptr < inend && (*inptr == ' ' || *inptr == '\t'))
> - inptr++;
> - headers->saw_nl = FALSE;
> - continue;
> - }
> - headers->saw_nl = FALSE;
> -
> - if (*inptr != '\r')
> - *lineptr++ = *inptr;
> - inptr++;
> - }
> - if (headers->saw_nl) {
> - *lineptr = '\0';
> - output_decoded_header (headers, &outptr);
> - lineptr = headers->line;
> - }
> - headers->lineptr = lineptr;
> - *outlen = outptr - filter->outbuf;
> - *outprespace = filter->outpre;
> - *outbuf = filter->outbuf;
> -}
> -
> -static void
> -filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
> - char **outbuf, size_t *outlen, size_t *outprespace)
> -{
> - if (inbuf && inlen)
> - filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
> -}
> -
> -static void
> -filter_reset (GMimeFilter *filter)
> -{
> - GMimeFilterHeaders *headers = (GMimeFilterHeaders *) filter;
> -
> - headers->saw_nl = TRUE;
> - free(headers->line);
> - headers->line = NULL;
> - headers->line_size = 0;
> -}
> -
> -
> -/**
> - * g_mime_filter_headers_new:
> - * @encode: %TRUE if the filter should encode or %FALSE otherwise
> - * @dots: encode/decode dots (as for SMTP)
> - *
> - * Creates a new #GMimeFilterHeaders filter.
> - *
> - * If @encode is %TRUE, then all lines will be prefixed by "> ",
> - * otherwise any lines starting with "> " will have that removed
> - *
> - * Returns: a new #GMimeFilterHeaders filter.
> - **/
> -GMimeFilter *
> -g_mime_filter_headers_new (void)
> -{
> - GMimeFilterHeaders *new_headers;
> -
> - new_headers = (GMimeFilterHeaders *) g_object_newv (GMIME_TYPE_FILTER_HEADERS, 0, NULL);
> -
> - return (GMimeFilter *) new_headers;
> -}
> -
> diff --git a/gmime-filter-headers.h b/gmime-filter-headers.h
> deleted file mode 100644
> index 1d1a3eb..0000000
> --- a/gmime-filter-headers.h
> +++ /dev/null
> @@ -1,69 +0,0 @@
> -/*
> - * Copyright © 2009 Keith Packard <keithp@keithp.com>
> - * Copyright © 2010 Michal Sojka <sojkam1@fel.cvut.cz>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation, either version 3 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write to the Free Software Foundation, Inc.,
> - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> - */
> -
> -#ifndef _GMIME_FILTER_HEADERS_H_
> -#define _GMIME_FILTER_HEADERS_H_
> -
> -#include <gmime/gmime-filter.h>
> -
> -G_BEGIN_DECLS
> -
> -#define GMIME_TYPE_FILTER_HEADERS (g_mime_filter_headers_get_type ())
> -#define GMIME_FILTER_HEADERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeaders))
> -#define GMIME_FILTER_HEADERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))
> -#define GMIME_IS_FILTER_HEADERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER_HEADERS))
> -#define GMIME_IS_FILTER_HEADERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER_HEADERS))
> -#define GMIME_FILTER_HEADERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER_HEADERS, GMimeFilterHeadersClass))
> -
> -typedef struct _GMimeFilterHeaders GMimeFilterHeaders;
> -typedef struct _GMimeFilterHeadersClass GMimeFilterHeadersClass;
> -
> -/**
> - * GMimeFilterHeaders:
> - * @parent_object: parent #GMimeFilter
> - * @saw_nl: previous char was a \n
> - * @line: temporary buffer for line unfolding
> - * @line_size: size of currently allocated memory for @line
> - * @lineptr: pointer to the first unused character in @line
> - *
> - * A filter to decode rfc2047 encoded headers
> - **/
> -struct _GMimeFilterHeaders {
> - GMimeFilter parent_object;
> -
> - gboolean saw_nl;
> - char *line;
> - size_t line_size;
> - char *lineptr;
> -};
> -
> -struct _GMimeFilterHeadersClass {
> - GMimeFilterClass parent_class;
> -
> -};
> -
> -
> -GType g_mime_filter_headers_get_type (void);
> -
> -GMimeFilter *g_mime_filter_headers_new (void);
> -
> -G_END_DECLS
> -
> -
> -#endif /* _GMIME_FILTER_HEADERS_H_ */
> diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
> index ac76b07..e553145 100644
> --- a/man/man1/notmuch-reply.1
> +++ b/man/man1/notmuch-reply.1
> @@ -41,7 +41,7 @@ include
> .RS
> .TP 4
> .BR default
> -Includes subject and quoted message body.
> +Includes subject and quoted message body as an RFC 2822 message.
> .TP
> .BR json
> Produces JSON output containing headers for a reply message and the
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 0f3b9cd..bfd0f51 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -21,28 +21,17 @@
> */
>
> #include "notmuch-client.h"
> -#include "gmime-filter-headers.h"
> #include "sprinter.h"
>
> static void
> show_reply_headers (GMimeMessage *message)
> {
> - GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
> + GMimeStream *stream_stdout = NULL;
>
> stream_stdout = g_mime_stream_file_new (stdout);
> if (stream_stdout) {
> g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
> - stream_filter = g_mime_stream_filter_new(stream_stdout);
> - if (stream_filter) {
> - // g_mime_object_write_to_stream will produce
> - // RFC2047-encoded headers, but we want to present the
> - // user with decoded headers and let whatever
> - // ultimately sends the mail do the RFC2047 encoding.
> - g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
> - g_mime_filter_headers_new());
> - g_mime_object_write_to_stream(GMIME_OBJECT(message), stream_filter);
> - g_object_unref(stream_filter);
> - }
> + g_mime_object_write_to_stream (GMIME_OBJECT(message), stream_stdout);
> g_object_unref(stream_stdout);
> }
> }
> diff --git a/test/reply b/test/reply
> index a85ebe5..d4389cf 100755
> --- a/test/reply
> +++ b/test/reply
> @@ -132,7 +132,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than
> '[body]="200-byte header"'
> output=$(notmuch reply id:${gen_msg_id})
> test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
> -Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces
> +Subject: Re: This subject is exactly 200 bytes in length. Other than its
> + length there is not much of note here. Note that the length of 200 bytes
> + includes the Subject: and Re: prefixes with two spaces
> In-Reply-To: <${gen_msg_id}>
> References: <${gen_msg_id}>
>
> @@ -200,10 +202,11 @@ add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
> '[body]="Encoding"'
>
> output=$(notmuch reply id:${gen_msg_id})
> +# Note that GMime changes from Q- to B-encoding
> test_expect_equal "$output" "\
> From: Notmuch Test Suite <test_suite@notmuchmail.org>
> -Subject: Re: àßç
> -To: ☃ <snowman@example.com>
> +Subject: Re: =?iso-8859-1?b?4N/n?=
> +To: =?UTF-8?b?4piD?= <snowman@example.com>
> In-Reply-To: <${gen_msg_id}>
> References: <${gen_msg_id}>
>
> diff --git a/test/reply-to-sender b/test/reply-to-sender
> index c7d15bb..30e5e38 100755
> --- a/test/reply-to-sender
> +++ b/test/reply-to-sender
> @@ -200,7 +200,9 @@ add_message '[subject]="This subject is exactly 200 bytes in length. Other than
> '[body]="200-byte header"'
> output=$(notmuch reply --reply-to=sender id:${gen_msg_id})
> test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
> -Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces
> +Subject: Re: This subject is exactly 200 bytes in length. Other than its
> + length there is not much of note here. Note that the length of 200 bytes
> + includes the Subject: and Re: prefixes with two spaces
> In-Reply-To: <${gen_msg_id}>
> References: <${gen_msg_id}>
>
--
Austin Clements MIT/'06/PhD/CSAIL
amdragon@mit.edu http://web.mit.edu/amdragon
Somewhere in the dream we call reality you will find me,
searching for the reality we call dreams.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers
2013-08-12 18:40 ` [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers Austin Clements
@ 2013-08-13 16:13 ` Austin Clements
0 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-13 16:13 UTC (permalink / raw)
To: notmuch
On Mon, 12 Aug 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> ---
> test/reply | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> diff --git a/test/reply b/test/reply
> index ee5d361..a85ebe5 100755
> --- a/test/reply
> +++ b/test/reply
> @@ -193,4 +193,60 @@ References: <${gen_msg_id}>
> On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
> > From guessing"
>
> +test_begin_subtest "Reply with RFC 2047-encoded headers"
> +add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
> + '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
> + '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
> + '[body]="Encoding"'
> +
> +output=$(notmuch reply id:${gen_msg_id})
> +test_expect_equal "$output" "\
> +From: Notmuch Test Suite <test_suite@notmuchmail.org>
> +Subject: Re: àßç
> +To: ☃ <snowman@example.com>
> +In-Reply-To: <${gen_msg_id}>
> +References: <${gen_msg_id}>
> +
> +On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
> +> Encoding"
> +
> +test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
> +output=$(notmuch reply --format=json id:${gen_msg_id})
> +test_expect_equal_json "$output" '
> +{
> + "original": {
> + "body": [
> + {
> + "content": "Encoding\n",
> + "content-type": "text/plain",
> + "id": 1
> + }
> + ],
> + "date_relative": "2010-01-05",
> + "excluded": false,
> + "filename": "'${MAIL_DIR}'/msg-012",
> + "headers": {
> + "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
> + "From": "\u2603 <snowman@example.com>",
> + "Subject": "\u00e0\u00df\u00e7",
> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
> + },
> + "id": "'${gen_msg_id}'",
> + "match": false,
> + "tags": [
> + "inbox",
> + "unread"
> + ],
> + "timestamp": 1262706236
> + },
> + "reply-headers": {
> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
> + "In-reply-to": "<'${gen_msg_id}'>",
> + "References": "<'${gen_msg_id}'>",
I screwed up when I was rebasing patches in this series. There's
supposed to be a space before the < above, which should then be removed
in patch 5. If people take a look over this series, I'll fix this along
with the commit message typo in v2.
> + "Subject": "Re: \u00e0\u00df\u00e7",
> + "To": "\u2603 <snowman@example.com>"
> + }
> +}'
> +
> +
> test_done
> --
> 1.7.10.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] Clean up reply's encoding story
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
` (5 preceding siblings ...)
2013-08-12 18:40 ` [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template Austin Clements
@ 2013-08-14 17:04 ` Tomi Ollila
2013-08-14 17:20 ` Austin Clements
6 siblings, 1 reply; 12+ messages in thread
From: Tomi Ollila @ 2013-08-14 17:04 UTC (permalink / raw)
To: Austin Clements, notmuch
On Mon, Aug 12 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> Jeff Stedfast's email about gmime-filter-headers.c possibly being
> unnecessary with GMime 2.6 (quoted in id:87bo56viyo.fsf@nikula.org)
> sent me on a wild goose chase that led to this patch series. It
> turned out that we *did* need gmime-filter-headers for what we were
> doing in the reply text format, but what we were doing made no sense.
> Patches 1 through 4 are simply the documentation and tests that I left
> in my wake and are harmless to push. Patch 6 is my conclusion that
> how we were handling header encoding in the text reply format made no
> sense. Patch 5 is a step toward patch 6, but makes sense on its own
> even if we decide against patch 6.
The whole series Looks Good To Me (sans known hiccups). I tested the patch 6
affecting 'default' output of notmuch reply bot not json or sexp output
(which I found surprising as so much code was removed). All the explations
in id:1376332839-22825-7-git-send-email-amdragon@mit.edu makes good sense
(but fix also 'tmeplate').
A slighly related note: ^M:s ^J:s (among other chars) don't get encoded
into =?utf-8?b?...?= ...
... also interestingly if U+202E (LEFT-TO-RIGHT OVERRIDE) is in (at least
From) header it disappears from `notmuch reply` default format. In json
and sexp format it disappears in 'reply-headers' but exists in 'headers'.
emacs client seems to use reply-headers as none of the header text lines
in buffer is rendered RTL.
Tomi
>
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] Clean up reply's encoding story
2013-08-14 17:04 ` [PATCH 0/6] Clean up reply's encoding story Tomi Ollila
@ 2013-08-14 17:20 ` Austin Clements
0 siblings, 0 replies; 12+ messages in thread
From: Austin Clements @ 2013-08-14 17:20 UTC (permalink / raw)
To: Tomi Ollila; +Cc: notmuch
Quoth Tomi Ollila on Aug 14 at 8:04 pm:
> On Mon, Aug 12 2013, Austin Clements <amdragon@MIT.EDU> wrote:
>
> > Jeff Stedfast's email about gmime-filter-headers.c possibly being
> > unnecessary with GMime 2.6 (quoted in id:87bo56viyo.fsf@nikula.org)
> > sent me on a wild goose chase that led to this patch series. It
> > turned out that we *did* need gmime-filter-headers for what we were
> > doing in the reply text format, but what we were doing made no sense.
> > Patches 1 through 4 are simply the documentation and tests that I left
> > in my wake and are harmless to push. Patch 6 is my conclusion that
> > how we were handling header encoding in the text reply format made no
> > sense. Patch 5 is a step toward patch 6, but makes sense on its own
> > even if we decide against patch 6.
>
> The whole series Looks Good To Me (sans known hiccups). I tested the patch 6
> affecting 'default' output of notmuch reply bot not json or sexp output
> (which I found surprising as so much code was removed). All the explations
> in id:1376332839-22825-7-git-send-email-amdragon@mit.edu makes good sense
> (but fix also 'tmeplate').
>
> A slighly related note: ^M:s ^J:s (among other chars) don't get encoded
> into =?utf-8?b?...?= ...
Do you mean when sending mail, or when replying to a message with
encoded ^Ms and ^Js?
> ... also interestingly if U+202E (LEFT-TO-RIGHT OVERRIDE) is in (at least
> From) header it disappears from `notmuch reply` default format. In json
> and sexp format it disappears in 'reply-headers' but exists in 'headers'.
> emacs client seems to use reply-headers as none of the header text lines
> in buffer is rendered RTL.
Cool. My guess would be that one of these it coming from notmuch's
internal header parser (via notmuch_message_get_header) and the other
is coming from GMime's header parser (used in notmuch-show.c)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/6] reply: Document the reason for g_mime_filter_headers
2013-08-12 18:40 ` [PATCH 3/6] reply: Document the reason for g_mime_filter_headers Austin Clements
@ 2013-08-15 8:40 ` David Bremner
0 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2013-08-15 8:40 UTC (permalink / raw)
To: Austin Clements, notmuch
Austin Clements <amdragon@MIT.EDU> writes:
> Given how long it took me to figure out why we pass the reply headers
> through g_mime_filter_headers, it's worth a comment.
> ---
Pushed the first 3 patches in the series.
d
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-08-15 8:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-12 18:40 [PATCH 0/6] Clean up reply's encoding story Austin Clements
2013-08-12 18:40 ` [PATCH 1/6] lib: Correct out-of-date doc comment Austin Clements
2013-08-12 18:40 ` [PATCH 2/6] lib: Document which strings are returned in UTF-8 Austin Clements
2013-08-12 18:40 ` [PATCH 3/6] reply: Document the reason for g_mime_filter_headers Austin Clements
2013-08-15 8:40 ` David Bremner
2013-08-12 18:40 ` [PATCH 4/6] reply: Test replying to messages with RFC 2047-encoded headers Austin Clements
2013-08-13 16:13 ` Austin Clements
2013-08-12 18:40 ` [PATCH 5/6] reply: Remove extraneous space from generated References Austin Clements
2013-08-12 18:40 ` [PATCH 6/6] reply: Use RFC 2822/MIME wholly for text format template Austin Clements
2013-08-12 20:01 ` Austin Clements
2013-08-14 17:04 ` [PATCH 0/6] Clean up reply's encoding story Tomi Ollila
2013-08-14 17:20 ` Austin Clements
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).