expand: Fix naked backslah leakage
commit1f1e555aba99808a82cb5090b5ef980714dea09c
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 1 May 2024 09:12:27 +0000 (1 17:12 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 12 May 2024 04:07:29 +0000 (12 12:07 +0800)
tree4dfd35fcaa16ce45b96093d7760990958a447237
parent43ffd41e7c8233af79cfb74ac416de290711459b
expand: Fix naked backslah leakage

Naked backslashes in patterns may incorrectly unquote subsequent
wild characters that are themselves quoted.  Fix this by adding
an extra backslash when necessary.

Test case:

a="\\*bc"; b="\\"; c="*"; echo "<${a##$b"$c"}>"

Old result:

<>

New result:

<bc>

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
src/expand.c
src/mystring.c
src/mystring.h