Module Name: src
Committed By: rillig
Date: Fri Jun 25 15:56:02 UTC 2021
Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk
Log Message:
tests/make: demonstrate newline injection in .for loop
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-for-escape.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.10
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9 Thu Jun 24 23:22:17 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp Fri Jun 25 15:56:02 2021
@@ -79,4 +79,18 @@ For: loop body:
make: "directive-for-escape.mk" line 118: eight $$$$ and no cents.
make: "directive-for-escape.mk" line 119: eight dollardollardollardollar and no cents.
make: "directive-for-escape.mk" line 128: eight and no cents.
-exit status 0
+For: end for 1
+For: loop body:
+. info short: ${:U"
+"}
+. info long: ${:U"
+"}
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 134: short: "
+make: "directive-for-escape.mk" line 135: Invalid line type
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 136: long: "
+make: "directive-for-escape.mk" line 137: Invalid line type
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.9
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8 Thu Jun 24 23:22:17 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk Fri Jun 25 15:56:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.8 2021/06/24 23:22:17 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.9 2021/06/25 15:56:02 rillig Exp $
#
# Test escaping of special characters in the iteration values of a .for loop.
# These values get expanded later using the :U variable modifier, and this
@@ -127,4 +127,12 @@ closing-brace= } # guard against an
${closing-brace}= <closing-brace> # alternative interpretation
.info eight ${$}${$}${$}${$} and no cents.
+# What happens if the values from the .for loop contain a literal newline?
+# Oops, the newline is added verbatim to the loop body, where it is later
+# interpreted as an ordinary newline.
+.for i in "${.newline}"
+. info short: $i
+. info long: ${i}
+.endfor
+
all: