summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 75c962c)
raw | patch | inline | side by side (parent: 75c962c)
author | Jeff King <peff@peff.net> | |
Wed, 28 Mar 2007 21:52:09 +0000 (17:52 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 28 Mar 2007 22:06:18 +0000 (15:06 -0700) |
The function replace_encoding_header is given the whole
commit buffer, including the commit message. When looking
for the encoding header, if none was found in the header, it
would locate any line in the commit message matching
"\nencoding " and remove it.
Instead, we now make sure to search only to the end of the
header.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
commit buffer, including the commit message. When looking
for the encoding header, if none was found in the header, it
would locate any line in the commit message matching
"\nencoding " and remove it.
Instead, we now make sure to search only to the end of the
header.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
commit.c | patch | blob | history |
diff --git a/commit.c b/commit.c
index 3e8c87294bc9e0cdbab40d485f75e3980ae4ff10..1fe23b6e3a9d4bf46948be2b19a96049d944bb1a 100644 (file)
--- a/commit.c
+++ b/commit.c
static char *replace_encoding_header(char *buf, char *encoding)
{
char *encoding_header = strstr(buf, "\nencoding ");
+ char *header_end = strstr(buf, "\n\n");
char *end_of_encoding_header;
int encoding_header_pos;
int encoding_header_len;
int need_len;
int buflen = strlen(buf) + 1;
- if (!encoding_header)
- return buf; /* should not happen but be defensive */
+ if (!header_end)
+ header_end = buf + buflen;
+ if (!encoding_header || encoding_header >= header_end)
+ return buf;
encoding_header++;
end_of_encoding_header = strchr(encoding_header, '\n');
if (!end_of_encoding_header)