Browse Source

format-patch: rfc2047-encode newlines in headers

These should generally never happen, as we already
concatenate multiples in subjects into a single line. But
let's be defensive, since not encoding them means we will
output malformed headers.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jeff King 14 years ago committed by Junio C Hamano
parent
commit
c22e7de340
  1. 4
      pretty.c

4
pretty.c

@ -228,7 +228,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, int len, @@ -228,7 +228,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, int len,

for (i = 0; i < len; i++) {
int ch = line[i];
if (non_ascii(ch))
if (non_ascii(ch) || ch == '\n')
goto needquote;
if ((i + 1 < len) && (ch == '=' && line[i+1] == '?'))
goto needquote;
@ -254,7 +254,7 @@ needquote: @@ -254,7 +254,7 @@ needquote:
* many programs do not understand this and just
* leave the underscore in place.
*/
if (is_rfc2047_special(ch) || ch == ' ') {
if (is_rfc2047_special(ch) || ch == ' ' || ch == '\n') {
strbuf_addf(sb, "=%02X", ch);
line_len += 3;
}

Loading…
Cancel
Save