You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
t: work around multibyte bug in quoted heredocs with Dash v0.5.13
When executing our test suite with Dash v0.5.13.2 one can observe
several test failures that all have the same symptoms: we have a quoted
heredoc that contains multibyte characters, but the final data does not
match what we actually wanted to write. One such example is in t0300,
where we see the diffs like the following:
--- expect-stdout 2026-04-01 07:25:45.249919440 +0000
+++ stdout 2026-04-01 07:25:45.254919509 +0000
@@ -1,5 +1,5 @@
protocol=https
host=example.com
-path=perú.git
+path=perú.git
username=foo
password=bar
While seemingly the same, the data that we've written via the heredoc
contains some invisible bytes. The expected hex representation of the
string is:
7065 72c3 ba2e 6769 74 per...git
But what we actually get instead is this string:
7065 7285 02c3 ba02 852e 6769 74 per.......git
What's important to note here is that the multibyte character exists in
both versions. But in the broken version we see that the bytes are
wrapped in a sequence of "85 02" and "02 85". This is the CTLMBCHAR byte
sequence of Dash, which it uses internally to quote multibyte sequences.
As it turns out, this bug was introduced in c5bf970 (expand: Add
multi-byte support to pmatch, 2024-06-02), which adds multibyte support
to more contexts of Dash. One of these contexts seems to be in heredocs,
and Dash _does_ correctly unquote these multibyte sequences when using
an unquoted heredoc. But the bug seems to be that this unquoting does
not happen in quoted heredocs, and the bug still exists on the latest
"master" branch.
For now, work around the bug by using unquoted heredocs instead.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
check_author "Foö Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"
1286
1286
'
1287
1287
1288
-
cat >expect <<'EOF'
1288
+
# NOTE: do not quote this heredoc, Dash 0.5.13 has a bug with heredocs
1289
+
# that contain multibyte chars.
1290
+
cat >expect <<EOF
1289
1291
From: Foö Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar
1290
1292
Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo
1291
1293
Bar Foo Bar Foo Bar Foo Bar <author@example.com>
@@ -1300,7 +1302,9 @@ test_expect_success 'format-patch wraps extremely long from-header (non-ASCII wi
1300
1302
test_cmp expect actual
1301
1303
'
1302
1304
1303
-
cat >expect <<'EOF'
1305
+
# NOTE: do not quote this heredoc, Dash 0.5.13 has a bug with heredocs
1306
+
# that contain multibyte chars.
1307
+
cat >expect <<EOF
1304
1308
Subject: [PATCH] Foö
1305
1309
EOF
1306
1310
test_expect_success 'subject lines are unencoded with --no-encode-email-headers''
@@ -1312,7 +1316,9 @@ test_expect_success 'subject lines are unencoded with --no-encode-email-headers'
1312
1316
test_cmp expect actual
1313
1317
'
1314
1318
1315
-
cat >expect <<'EOF'
1319
+
# NOTE: do not quote this heredoc, Dash 0.5.13 has a bug with heredocs
1320
+
# that contain multibyte chars.
1321
+
cat >expect <<EOF
1316
1322
Subject: [PATCH] Foö
1317
1323
EOF
1318
1324
test_expect_success 'subject lines are unencoded with format.encodeEmailHeaders=false''
0 commit comments