mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-05-20 23:41:27 +02:00
51417: Check subscripts in named reference values more rigorously.
This commit is contained in:
parent
acb15e3cc9
commit
f4c706f0c8
3 changed files with 15 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
|||
2023-02-12 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 51417: Src/params.c, Test/K01nameref.ztst: Check subscripts
|
||||
in named reference values more rigorously.
|
||||
|
||||
* 51403: Doc/Zsh/builtins.yo, Doc/Zsh/expn.yo, Doc/Zsh/func.yo,
|
||||
Doc/Zsh/grammar.yo, Doc/Zsh/params.yo, Test/K01nameref.ztst:
|
||||
Tests and documentation for 51402, clean up some other tests.
|
||||
|
|
11
Src/params.c
11
Src/params.c
|
@ -6281,7 +6281,16 @@ valid_refname(char *val)
|
|||
if (*t != 0) {
|
||||
if (*t == '[') {
|
||||
tokenize(t = dupstring(t+1));
|
||||
t = parse_subscript(t, 0, ']');
|
||||
while ((t = parse_subscript(t, 0, ']')) && *t++ == Outbrack) {
|
||||
if (*t == Inbrack)
|
||||
++t;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (t && *t) {
|
||||
/* zwarn("%s: stuff after subscript: %s", val, t); */
|
||||
t = NULL;
|
||||
}
|
||||
} else if (t[1] || !(*t == '!' || *t == '?' ||
|
||||
*t == '$' || *t == '-' ||
|
||||
*t == '0' || *t == '_')) {
|
||||
|
|
|
@ -350,9 +350,9 @@ F:ksh93 does not implement this either
|
|||
>typeset -A hash=( [y]=HIT )
|
||||
|
||||
unset -n ptr1
|
||||
typeset -n ptr1='not good'
|
||||
typeset -n ptr1='not[2]good'
|
||||
1:invalid nameref
|
||||
*?*invalid variable name: not good
|
||||
*?*invalid variable name: not\[2\]good
|
||||
|
||||
unset -n ptr1
|
||||
unset hash
|
||||
|
|
Loading…
Reference in a new issue