git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] imap-send: Remove limitation on message body

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 22, 2010, 18:07 UTC
Message-ID
<f3271551003221107w7a554c69scf43f2c99242808f@mail.gmail.com>

There is a documented limitation on the body of any email not being able to contain lines starting with "From ". This patch removes that limitation by improving the parser to search for "From", "Date", and "Subject" fields in the email before considering it to be an email.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
    v1 was git-imap-send bugfix: Allow lines starting with "From " in body
    v2 adds documentation about the email containing mandatory fields
 Documentation/git-imap-send.txt |   10 +++-------
 imap-send.c                     |    8 +++++++-
 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt
index 6cafbe2..57aba42 100644
--- a/Documentation/git-imap-send.txt
+++ b/Documentation/git-imap-send.txt
@@ -16,7 +16,9 @@ DESCRIPTION
 This command uploads a mailbox generated with 'git format-patch'
 into an IMAP drafts folder.  This allows patches to be sent as
 other email is when using mail clients that cannot read mailbox
-files directly.
+files directly. The command also works with any general mailbox
+in which emails have the fields "From", "Date", and "Subject" in
+that order.

 Typical usage is something like:

@@ -122,12 +124,6 @@ Thunderbird in particular is known to be
problematic.  Thunderbird
 users may wish to visit this web page for more information:
   http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email

-
-BUGS
-----
-Doesn't handle lines starting with "From " in the message body.
-
-
 Author
 ------
 Derived from isync 1.0.1 by Mike McCormack.
diff --git a/imap-send.c b/imap-send.c
index aeb2985..2623862 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)

 	while (1) {
 		if (!prefixcmp(p, "From ")) {
+			p = strstr(p+5, "\nFrom: ");
+			if (!p) break;
+			p = strstr(p+7, "\nDate: ");
+			if (!p) break;
+			p = strstr(p+7, "\nSubject: ");
+			if (!p) break;
+			p += 10;
 			count++;
-			p += 5;
 		}
 		p = strstr(p+5, "\nFrom ");
 		if (!p)
-- 
1.7.0.2
Message 1 of 1 in “imap-send: Remove limitation on message body”
  1. imap-send: Remove limitation on message bodyRamkumar Ramachandra, Mar 22, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.