mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
dump: Disallow \n in message IDs
When we switch to using regular Xapian queries in the dump format, \n will cause problems, so we disallow it. Specially, while Xapian can quote and parse queries containing \n without difficultly, quoted queries containing \n still span multiple lines, which breaks the line-orientedness of the dump format. Strictly speaking, we could still round-trip these, but it would significantly complicate restore as well as scripts that deal with tag dumps. This complexity would come at absolutely no benefit: because of the RFC 2822 unfolding rules, no amount of standards negligence can produce a message with a message ID containing a line break (not even Outlook can do it!). Hence, we simply disallow it.
This commit is contained in:
parent
7c3a995d6b
commit
d08c714b6a
2 changed files with 15 additions and 1 deletions
|
@ -102,6 +102,18 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
|
|||
message = notmuch_messages_get (messages);
|
||||
message_id = notmuch_message_get_message_id (message);
|
||||
|
||||
if (output_format == DUMP_FORMAT_BATCH_TAG &&
|
||||
strchr (message_id, '\n')) {
|
||||
/* This will produce a line break in the output, which
|
||||
* would be difficult to handle in tools. However, it's
|
||||
* also impossible to produce an email containing a line
|
||||
* break in a message ID because of unfolding, so we can
|
||||
* safely disallow it. */
|
||||
fprintf (stderr, "Warning: skipping message id containing line break: \"%s\"\n", message_id);
|
||||
notmuch_message_destroy (message);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (output_format == DUMP_FORMAT_SUP) {
|
||||
fprintf (output, "%s (", message_id);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,9 @@ random_utf8_string (void *ctx, size_t char_count)
|
|||
buf = talloc_realloc (ctx, buf, gchar, buf_size);
|
||||
}
|
||||
|
||||
do {
|
||||
randomchar = random_unichar ();
|
||||
} while (randomchar == '\n');
|
||||
|
||||
written = g_unichar_to_utf8 (randomchar, buf + offset);
|
||||
|
||||
|
|
Loading…
Reference in a new issue