1
0
mirror of https://github.com/git/git.git synced 2024-09-23 12:01:15 +02:00

mailinfo: off-by-one fix for [PATCH (foobar)] removal from Subject: line

A patch title "[PATCH] 1" was sanitized by the original code by stripping
the "[PATCH]" from the front, but after the conversion to use strbuf this
behaviour was broken due to a counting error.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2008-07-16 22:42:04 -07:00
parent 3bf0dd1f4e
commit 1e102bf7c8

View File

@ -225,10 +225,9 @@ static void cleanup_subject(struct strbuf *subject)
continue; continue;
case '[': case '[':
if ((pos = strchr(subject->buf, ']'))) { if ((pos = strchr(subject->buf, ']'))) {
remove = pos - subject->buf + 1; remove = pos - subject->buf;
/* Don't remove too much. */ if (remove <= (subject->len - remove) * 2) {
if (remove <= (subject->len - remove + 1) * 2) { strbuf_remove(subject, 0, remove + 1);
strbuf_remove(subject, 0, remove);
continue; continue;
} }
} else } else