aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Sasburg <simon.sasburg@gmail.com>2007-11-01 23:57:45 +0100
committerJunio C Hamano <gitster@pobox.com>2007-11-02 01:58:40 -0700
commitf88a545a94cb474d370ef97dd3694d09b6ac90c1 (patch)
tree6c897e2743260174fb849198b4a7c2b5a15f350b
parent3e4bb087a18435b12eb82116e93af2887578e816 (diff)
downloadgit-f88a545a94cb474d370ef97dd3694d09b6ac90c1.tar.gz
git-f88a545a94cb474d370ef97dd3694d09b6ac90c1.tar.xz
Make mailsplit and mailinfo strip whitespace from the start of the input
Signed-off-by: Simon Sasburg <Simon.Sasburg@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-mailinfo.c6
-rw-r--r--builtin-mailsplit.c6
-rw-r--r--t/t5100/sample.mbox3
3 files changed, 15 insertions, 0 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index fb12248f8..260084797 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -915,6 +915,7 @@ static void handle_info(void)
static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
const char *msg, const char *patch)
{
+ int peek;
keep_subject = ks;
metainfo_charset = encoding;
fin = in;
@@ -935,6 +936,11 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
+ do {
+ peek = fgetc(in);
+ } while (isspace(peek));
+ ungetc(peek, in);
+
/* process the email header */
while (read_one_header_line(line, sizeof(line), fin))
check_header(line, sizeof(line), p_hdr_data, 1);
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 43fc373a1..74b04706f 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -164,6 +164,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
{
char name[PATH_MAX];
int ret = -1;
+ int peek;
FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
int file_done = 0;
@@ -173,6 +174,11 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
goto out;
}
+ do {
+ peek = fgetc(f);
+ } while (isspace(peek));
+ ungetc(peek, f);
+
if (fgets(buf, sizeof(buf), f) == NULL) {
/* empty stdin is OK */
if (f != stdin) {
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index b80c981c1..070c1661b 100644
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
@@ -1,3 +1,6 @@
+
+
+
From nobody Mon Sep 17 00:00:00 2001
From: A U Thor <a.u.thor@example.com>
Date: Fri, 9 Jun 2006 00:44:16 -0700