Skip to content

Commit c22e7de

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a1f6baa commit c22e7de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pretty.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, int len,
228228

229229
for (i = 0; i < len; i++) {
230230
int ch = line[i];
231-
if (non_ascii(ch))
231+
if (non_ascii(ch) || ch == '\n')
232232
goto needquote;
233233
if ((i + 1 < len) && (ch == '=' && line[i+1] == '?'))
234234
goto needquote;
@@ -254,7 +254,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, int len,
254254
* many programs do not understand this and just
255255
* leave the underscore in place.
256256
*/
257-
if (is_rfc2047_special(ch) || ch == ' ') {
257+
if (is_rfc2047_special(ch) || ch == ' ' || ch == '\n') {
258258
strbuf_addf(sb, "=%02X", ch);
259259
line_len += 3;
260260
}

0 commit comments

Comments
 (0)