summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-15 14:59:01 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-15 14:59:01 +0000
commit0e5666e2adf19dc86457a958a622a6f58c9f9ff0 (patch)
tree48d87dff657b3ec7f34d4deb7989a77ce69e3fef /Src/subst.c
parent1dc5677a419456cc23a5e9fa763fc01c35ff1791 (diff)
downloadzsh-0e5666e2adf19dc86457a958a622a6f58c9f9ff0.tar.gz
zsh-0e5666e2adf19dc86457a958a622a6f58c9f9ff0.tar.xz
zsh-0e5666e2adf19dc86457a958a622a6f58c9f9ff0.zip
detect additional characters in parameter expansions and signal an error for them (11380)
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 1dc952083..94a1222d8 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1230,6 +1230,15 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	if (!inbrace)
 	    break;
     }
+    if (inbrace &&
+	(c = *s) != '-' && c != '+' && c != ':' && c != '%'  && c != '/' &&
+	c != '=' && c != Equals &&
+	c != '#' && c != Pound &&
+	c != '?' && c != Quest &&
+	c != '}' && c != Outbrace) {
+	zerr("bad substitution", NULL, 0);
+	return NULL;
+    }
     if (isarr) {
 	if (nojoin)
 	    isarr = -1;
@@ -1463,9 +1472,6 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		}
 	    }
 	    {
-		char t = s[-1];
-
-		singsub(&s);
 #if 0
 		/*
 		 * This allows # and % to be at the start of
@@ -1473,6 +1479,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		 * a bit nasty, and can be done (although
 		 * less efficiently) with anchors.
 		 */
+
+		char t = s[-1];
+
+		singsub(&s);
+
 		if (t == '/' && (flags & SUB_SUBSTR)) {
 		    if ((c = *s) == '#' || c == '%') {
 			flags &= ~SUB_SUBSTR;
@@ -1483,6 +1494,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 			s++;
 		    }
 		}
+#else
+		singsub(&s);
 #endif
 	    }