summaryrefslogtreecommitdiffstats
path: root/t/t5001-archive-attr.sh
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-02-28 12:22:47 +0100
committerJunio C Hamano <gitster@pobox.com>2021-03-11 22:22:44 +0100
commit96099726ddb00b45135964220ce56468ba9fe184 (patch)
tree67511a24e20bf148d232a8595719cb8bf48d4077 /t/t5001-archive-attr.sh
parentpretty: document multiple %(describe) being inconsistent (diff)
downloadgit-96099726ddb00b45135964220ce56468ba9fe184.tar.xz
git-96099726ddb00b45135964220ce56468ba9fe184.zip
archive: expand only a single %(describe) per archive
Every %(describe) placeholder in $Format:...$ strings in files with the attribute export-subst is expanded by calling git describe. This can potentially result in a lot of such calls per archive. That's OK for local repositories under control of the user of git archive, but could be a problem for hosted repositories. Expand only a single %(describe) placeholder per archive for now to avoid denial-of-service attacks. We can make this limit configurable later if needed, but let's start out simple. Reported-by: Jeff King <peff@peff.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5001-archive-attr.sh')
-rwxr-xr-xt/t5001-archive-attr.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh
index e9aa97117a..712ae52299 100755
--- a/t/t5001-archive-attr.sh
+++ b/t/t5001-archive-attr.sh
@@ -128,4 +128,18 @@ test_expect_success 'export-subst' '
test_cmp substfile2 archive/substfile2
'
+test_expect_success 'export-subst expands %(describe) once' '
+ echo "\$Format:%(describe)\$" >substfile3 &&
+ echo "\$Format:%(describe)\$" >>substfile3 &&
+ echo "\$Format:%(describe)${LF}%(describe)\$" >substfile4 &&
+ git add substfile[34] &&
+ git commit -m export-subst-describe &&
+ git tag -m export-subst-describe export-subst-describe &&
+ git archive HEAD >archive-describe.tar &&
+ extract_tar_to_dir archive-describe &&
+ desc=$(git describe) &&
+ grep -F "$desc" archive-describe/substfile[34] >substituted &&
+ test_line_count = 1 substituted
+'
+
test_done