{"thread":{"id":"23144","subject":"[PATCH v2] imap-send: Remove limitation on message body","startedAt":"2010-03-22T18:07:52Z","lastAt":"2010-03-22T18:07:52Z","messageCount":1,"participants":["Ramkumar Ramachandra"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"137573","messageId":"f3271551003221107w7a554c69scf43f2c99242808f@mail.gmail.com","threadId":"23144","inReplyTo":null,"subject":"[PATCH v2] imap-send: Remove limitation on message body","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-03-22T18:07:52Z","receivedAt":"2010-03-22T18:07:52Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"There is a documented limitation on the body of any email not being\nable to contain lines starting with \"From \". This patch removes that\nlimitation by improving the parser to search for \"From\", \"Date\", and\n\"Subject\" fields in the email before considering it to be an email.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n    v1 was git-imap-send bugfix: Allow lines starting with \"From \" in body\n    v2 adds documentation about the email containing mandatory fields\n\n Documentation/git-imap-send.txt |   10 +++-------\n imap-send.c                     |    8 +++++++-\n 2 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt\nindex 6cafbe2..57aba42 100644\n--- a/Documentation/git-imap-send.txt\n+++ b/Documentation/git-imap-send.txt\n@@ -16,7 +16,9 @@ DESCRIPTION\n This command uploads a mailbox generated with 'git format-patch'\n into an IMAP drafts folder.  This allows patches to be sent as\n other email is when using mail clients that cannot read mailbox\n-files directly.\n+files directly. The command also works with any general mailbox\n+in which emails have the fields \"From\", \"Date\", and \"Subject\" in\n+that order.\n\n Typical usage is something like:\n\n@@ -122,12 +124,6 @@ Thunderbird in particular is known to be\nproblematic.  Thunderbird\n users may wish to visit this web page for more information:\n   http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email\n\n-\n-BUGS\n-----\n-Doesn't handle lines starting with \"From \" in the message body.\n-\n-\n Author\n ------\n Derived from isync 1.0.1 by Mike McCormack.\ndiff --git a/imap-send.c b/imap-send.c\nindex aeb2985..2623862 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)\n\n \twhile (1) {\n \t\tif (!prefixcmp(p, \"From \")) {\n+\t\t\tp = strstr(p+5, \"\\nFrom: \");\n+\t\t\tif (!p) break;\n+\t\t\tp = strstr(p+7, \"\\nDate: \");\n+\t\t\tif (!p) break;\n+\t\t\tp = strstr(p+7, \"\\nSubject: \");\n+\t\t\tif (!p) break;\n+\t\t\tp += 10;\n \t\t\tcount++;\n-\t\t\tp += 5;\n \t\t}\n \t\tp = strstr(p+5, \"\\nFrom \");\n \t\tif (!p)\n-- \n1.7.0.2\n"}]}