Skip to content

Commit 437a9ac

Browse files
committed
Handle quotes in From: lines correctly.
We correctly enclose "<author> via GitGitGadget" in double quotes, but if <author> already contained double quotes (e.g. because it contains dots), we failed to strip/escape them. This prevented gitgitgadget/git#435 from being sent correctly (it was sent all right, but the Git mailing list dropped the mails unceremoniously). Let's handle this correctly. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent fb2b3e6 commit 437a9ac

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

lib/patch-series.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ export class PatchSeries {
376376
// Special-case GitGitGadget to send from
377377
// "<author> via GitGitGadget"
378378
replaceSender = "\""
379-
+ onBehalfOf
379+
+ onBehalfOf.replace(/^"(.*)"$/, "$1")
380+
.replace(/"/g, "\\\"")
380381
+ " via GitGitGadget\" "
381382
+ thisAuthor.replace(/^GitGitGadget /, "");
382383
} else if (authorMatch[2] === thisAuthor) {

tests/gitgitgadget.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { testCreateRepo } from "./test-lib";
1010
jest.setTimeout(60000);
1111

1212
const expectedMails = [
13-
`From 07f68c195159518c5777ca4a7c1d07124e7a9956 Mon Sep 17 00:00:00 2001
13+
`From 91fba7811291c1064b2603765a2297c34fc843c0 Mon Sep 17 00:00:00 2001
1414
Message-Id: <pull.<Message-ID>>
1515
From: "GitHub User via GitGitGadget" <[email protected]>
1616
Date: <Cover-Letter-Date>
@@ -31,7 +31,7 @@ Contributor (1):
3131
Developer (1):
3232
C
3333
34-
Test Dev (1):
34+
Test H. Dev (1):
3535
A
3636
3737
A.t | 1 +
@@ -43,7 +43,7 @@ Test Dev (1):
4343
create mode 100644 C.t
4444
4545
46-
base-commit: c241357a04a6f862ceef20bd148946085f3178b9
46+
base-commit: b4bc10cab67df9962ae52c82af9e1a43fd83d806
4747
Published-As: https://github.com/gitgitgadget/git/releases/tag/${
4848
"pr-1/somebody/master-v1".replace(/\//g, "%2F")}
4949
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git ${
@@ -52,11 +52,11 @@ Pull-Request: https://github.com/gitgitgadget/git/pull/1
5252
--${" "}
5353
gitgitgadget
5454
`,
55-
`From cd048a1378e3f7b055cd467ff3a24ed0cf5e7453 Mon Sep 17 00:00:00 2001
56-
Message-Id: <cd048a1378e3f7b055cd467ff3a24ed0cf5e7453.<Message-ID>>
55+
`From 3a632624f5927565b178664f9a12b9802d2714b1 Mon Sep 17 00:00:00 2001
56+
Message-Id: <3a632624f5927565b178664f9a12b9802d2714b1.<Message-ID>>
5757
In-Reply-To: <pull.<Message-ID>>
5858
References: <pull.<Message-ID>>
59-
From: "Test Dev via GitGitGadget" <[email protected]>
59+
From: "Test H. Dev via GitGitGadget" <[email protected]>
6060
Date: Fri, 13 Feb 2009 23:33:30 +0000
6161
Subject: [PATCH 1/3] A
6262
Fcc: Sent
@@ -65,9 +65,9 @@ Content-Transfer-Encoding: 8bit
6565
MIME-Version: 1.0
6666
6767
Cc: Some Body <[email protected]>,
68-
Test Dev <[email protected]>
68+
"Test H. Dev" <[email protected]>
6969
70-
From: Test Dev <[email protected]>
70+
From: "Test H. Dev" <[email protected]>
7171
7272
---
7373
A.t | 1 +
@@ -86,8 +86,8 @@ index 0000000..8c7e5a6
8686
gitgitgadget
8787
8888
`,
89-
`From b8acfa2635f9907e472d2b7396b260c6e73b1ed5 Mon Sep 17 00:00:00 2001
90-
Message-Id: <b8acfa2635f9907e472d2b7396b260c6e73b1ed5.<Message-ID>>
89+
`From 0076a21b90c6e1f4f380deb464fe7145d4a7a56d Mon Sep 17 00:00:00 2001
90+
Message-Id: <0076a21b90c6e1f4f380deb464fe7145d4a7a56d.<Message-ID>>
9191
In-Reply-To: <pull.<Message-ID>>
9292
References: <pull.<Message-ID>>
9393
From: "Contributor via GitGitGadget" <[email protected]>
@@ -120,8 +120,8 @@ index 0000000..7371f47
120120
gitgitgadget
121121
122122
`,
123-
`From 07f68c195159518c5777ca4a7c1d07124e7a9956 Mon Sep 17 00:00:00 2001
124-
Message-Id: <07f68c195159518c5777ca4a7c1d07124e7a9956.<Message-ID>>
123+
`From 91fba7811291c1064b2603765a2297c34fc843c0 Mon Sep 17 00:00:00 2001
124+
Message-Id: <91fba7811291c1064b2603765a2297c34fc843c0.<Message-ID>>
125125
In-Reply-To: <pull.<Message-ID>>
126126
References: <pull.<Message-ID>>
127127
From: "Developer via GitGitGadget" <[email protected]>
@@ -173,7 +173,7 @@ test("generate tag/notes from a Pull Request", async () => {
173173
expect(await notes.set("", gitGitGadgetOptions)).toBeUndefined();
174174
expect(await notes.get("")).toEqual(gitGitGadgetOptions);
175175

176-
await repo.git(["config", "user.name", "Test Dev"]);
176+
await repo.git(["config", "user.name", "Test H. Dev"]);
177177
await repo.git(["config", "user.email", "[email protected]"]);
178178

179179
expect(await repo.commit("initial")).not.toEqual("");
@@ -294,7 +294,7 @@ Developer (1):
294294
GitGitGadget (1):
295295
D
296296
297-
Test Dev (1):
297+
Test H. Dev (1):
298298
A
299299
300300
A.t | 1 +
@@ -307,7 +307,7 @@ Test Dev (1):
307307
create mode 100644 C.t
308308
create mode 100644 D.t
309309
310-
base-commit: c241357a04a6f862ceef20bd148946085f3178b9
310+
base-commit: b4bc10cab67df9962ae52c82af9e1a43fd83d806
311311
312312
Submitted-As: https://dummy.com/?mid=${coverMid}
313313
In-Reply-To: https://dummy.com/?mid=${refMid}`);

0 commit comments

Comments
 (0)