|
3 | 3 | test_description='git am with corrupt input'
|
4 | 4 | . ./test-lib.sh
|
5 | 5 |
|
| 6 | +make_mbox_with_nul () { |
| 7 | + space=' ' |
| 8 | + q_nul_in_subject= |
| 9 | + q_nul_in_body= |
| 10 | + while test $# -ne 0 |
| 11 | + do |
| 12 | + case "$1" in |
| 13 | + subject) q_nul_in_subject='=00' ;; |
| 14 | + body) q_nul_in_body='=00' ;; |
| 15 | + esac && |
| 16 | + shift |
| 17 | + done && |
| 18 | + cat <<-EOF |
| 19 | + From ec7364544f690c560304f5a5de9428ea3b978b26 Mon Sep 17 00:00:00 2001 |
| 20 | + From: A U Thor <[email protected]> |
| 21 | + Date: Sun, 19 Apr 2020 13:42:07 +0700 |
| 22 | + Subject: [PATCH] =?ISO-8859-1?q?=C4=CB${q_nul_in_subject}=D1=CF=D6?= |
| 23 | + MIME-Version: 1.0 |
| 24 | + Content-Type: text/plain; charset=ISO-8859-1 |
| 25 | + Content-Transfer-Encoding: quoted-printable |
| 26 | +
|
| 27 | + abc${q_nul_in_body}def |
| 28 | + --- |
| 29 | + diff --git a/afile b/afile |
| 30 | + new file mode 100644 |
| 31 | + index 0000000000..e69de29bb2 |
| 32 | + --$space |
| 33 | + 2.26.1 |
| 34 | + EOF |
| 35 | +} |
| 36 | + |
6 | 37 | test_expect_success setup '
|
7 | 38 | # Note the missing "+++" line:
|
8 | 39 | cat >bad-patch.diff <<-\EOF &&
|
@@ -32,4 +63,17 @@ test_expect_success 'try to apply corrupted patch' '
|
32 | 63 | test_i18ncmp expected actual
|
33 | 64 | '
|
34 | 65 |
|
| 66 | +test_expect_success "NUL in commit message's body" ' |
| 67 | + test_when_finished "git am --abort" && |
| 68 | + make_mbox_with_nul body >body.patch && |
| 69 | + test_must_fail git am body.patch 2>err && |
| 70 | + grep "a NUL byte in commit log message not allowed" err |
| 71 | +' |
| 72 | + |
| 73 | +test_expect_failure "NUL in commit message's header" " |
| 74 | + test_when_finished 'git am --abort' && |
| 75 | + make_mbox_with_nul subject >subject.patch && |
| 76 | + test_must_fail git am subject.patch |
| 77 | +" |
| 78 | + |
35 | 79 | test_done
|
0 commit comments