Skip to content

Commit 51e971d

Browse files
committed
Merge branch 'jc/neuter-sideband-post-3.0' into seen
The final step, split from earlier attempt by Dscho, to loosen the sideband restriction for now and tighten later at Git v3.0 boundary. Will retract. (this branch uses jc/neuter-sideband-fixup.) * jc/neuter-sideband-post-3.0: sideband: delay sanitizing by default to Git v3.0
2 parents e7bb3e3 + 818fbfd commit 51e971d

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

Documentation/config/sideband.adoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
sideband.allowControlCharacters::
2+
ifdef::with-breaking-changes[]
23
By default, control characters that are delivered via the sideband
34
are masked, except ANSI color sequences. This prevents potentially
4-
unwanted ANSI escape sequences from being sent to the terminal. Use
5-
this config setting to override this behavior (the value can be
5+
unwanted ANSI escape sequences from being sent to the terminal.
6+
endif::with-breaking-changes[]
7+
ifndef::with-breaking-changes[]
8+
By default, no control characters delivered via the sideband
9+
are masked. This is unsafe and will change in Git v3.* to only
10+
allow ANSI color sequences by default, preventing potentially
11+
unwanted ANSI escape sequences from being sent to the terminal.
12+
endif::with-breaking-changes[]
13+
Use this config setting to override this behavior (the value can be
614
a comma-separated list of the following keywords):
715
+
816
--

sideband.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ static enum {
3434
ALLOW_ANSI_CURSOR_MOVEMENTS = 1<<1,
3535
ALLOW_ANSI_ERASE = 1<<2,
3636
ALLOW_ALL_CONTROL_CHARACTERS = 1<<3,
37-
ALLOW_DEFAULT_ANSI_SEQUENCES = ALLOW_ANSI_COLOR_SEQUENCES
37+
#ifdef WITH_BREAKING_CHANGES
38+
ALLOW_DEFAULT_ANSI_SEQUENCES = ALLOW_ANSI_COLOR_SEQUENCES,
39+
#else
40+
ALLOW_DEFAULT_ANSI_SEQUENCES = ALLOW_ALL_CONTROL_CHARACTERS,
41+
#endif
3842
} allow_control_characters = ALLOW_CONTROL_SEQUENCES_UNSET;
3943

4044
static inline int skip_prefix_in_csv(const char *value, const char *prefix,

t/t5409-colorize-remote-messages.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ test_expect_success 'fallback to color.ui' '
9898
grep "<BOLD;RED>error<RESET>: error" decoded
9999
'
100100

101+
if test_have_prereq WITH_BREAKING_CHANGES
102+
then
103+
TURN_ON_SANITIZING=already.turned=on
104+
else
105+
TURN_ON_SANITIZING=sideband.allowControlCharacters=color
106+
fi
107+
101108
test_expect_success 'disallow (color) control sequences in sideband' '
102109
write_script .git/color-me-surprised <<-\EOF &&
103110
printf "error: Have you \\033[31mread\\033[m this?\\a\\n" >&2
@@ -106,7 +113,7 @@ test_expect_success 'disallow (color) control sequences in sideband' '
106113
test_config_global uploadPack.packObjectsHook ./color-me-surprised &&
107114
test_commit need-at-least-one-commit &&
108115
109-
git clone --no-local . throw-away 2>stderr &&
116+
git -c $TURN_ON_SANITIZING clone --no-local . throw-away 2>stderr &&
110117
test_decode_color <stderr >decoded &&
111118
test_grep RED decoded &&
112119
test_grep "\\^G" stderr &&
@@ -138,7 +145,7 @@ test_decode_csi() {
138145
}'
139146
}
140147

141-
test_expect_success 'control sequences in sideband allowed by default' '
148+
test_expect_success 'control sequences in sideband allowed by default (in Git v3.8)' '
142149
write_script .git/color-me-surprised <<-\EOF &&
143150
printf "error: \\033[31mcolor\\033[m\\033[Goverwrite\\033[Gerase\\033[K\\033?25l\\n" >&2
144151
exec "$@"
@@ -147,7 +154,7 @@ test_expect_success 'control sequences in sideband allowed by default' '
147154
test_commit need-at-least-one-commit-at-least &&
148155
149156
rm -rf throw-away &&
150-
git clone --no-local . throw-away 2>stderr &&
157+
git -c $TURN_ON_SANITIZING clone --no-local . throw-away 2>stderr &&
151158
test_decode_color <stderr >color-decoded &&
152159
test_decode_csi <color-decoded >decoded &&
153160
test_grep ! "CSI \\[K" decoded &&
@@ -175,14 +182,15 @@ test_expect_success 'allow all control sequences for a specific URL' '
175182
test_commit one-more-please &&
176183
177184
rm -rf throw-away &&
178-
git clone --no-local . throw-away 2>stderr &&
185+
git -c $TURN_ON_SANITIZING clone --no-local . throw-away 2>stderr &&
179186
test_decode_color <stderr >color-decoded &&
180187
test_decode_csi <color-decoded >decoded &&
181188
test_grep ! "CSI \\[K" decoded &&
182189
test_grep "\\^\\[\\[K" decoded &&
183190
184191
rm -rf throw-away &&
185-
git -c "sideband.file://.allowControlCharacters=true" \
192+
git -c sideband.allowControlCharacters=false \
193+
-c "sideband.file://.allowControlCharacters=true" \
186194
clone --no-local "file://$PWD" throw-away 2>stderr &&
187195
test_decode_color <stderr >color-decoded &&
188196
test_decode_csi <color-decoded >decoded &&

0 commit comments

Comments
 (0)