Skip to content

Commit d2ca120

Browse files
pks-tgitster
authored andcommitted
ci/lib: do not interpret escape sequences in group () arguments
We use printf to set up sections with GitLab CI, which requires us to print a bunch of escape sequences via printf. The group name is controlled by the user and is expanded directly into the formatting string, which may cause problems in case the argument contains escape sequences or formatting directives. Fix this potential issue by using formatting directives to pass variable data. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33b06fa commit d2ca120

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ci/lib.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ elif test true = "$GITLAB_CI"
1818
then
1919
begin_group () {
2020
need_to_end_group=t
21-
printf "\e[0Ksection_start:$(date +%s):$(echo "$1" | tr ' ' _)[collapsed=true]\r\e[0K$1\n"
21+
printf '\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K%s\n' \
22+
"$(date +%s)" "$(echo "$1" | tr ' ' _)" "$1"
2223
trap "end_group '$1'" EXIT
2324
set -x
2425
}
@@ -27,7 +28,8 @@ then
2728
test -n "$need_to_end_group" || return 0
2829
set +x
2930
need_to_end_group=
30-
printf "\e[0Ksection_end:$(date +%s):$(echo "$1" | tr ' ' _)\r\e[0K\n"
31+
printf '\e[0Ksection_end:%s:%s\r\e[0K\n' \
32+
"$(date +%s)" "$(echo "$1" | tr ' ' _)"
3133
trap - EXIT
3234
}
3335
else

0 commit comments

Comments
 (0)