bash/bash-5.0-glob-disable-slash.patch
Siteshwar Vashisht 3ee228b797 Disable unescaped slashes in bracket expressions
Resolves: RHEL-92267

Signed-off-by: Siteshwar Vashisht <svashisht@redhat.com>
2025-06-06 14:40:05 +02:00

41 lines
1.1 KiB
Diff

diff --git a/pathexp.c b/pathexp.c
--- a/pathexp.c
+++ b/pathexp.c
@@ -58,7 +58,10 @@ int extended_glob = EXTGLOB_DEFAULT;
/* Control enabling special handling of `**' */
int glob_star = 0;
-/* Return nonzero if STRING has any unquoted special globbing chars in it. */
+/* Return nonzero if STRING has any unquoted special globbing chars in it.
+ This is supposed to be called when pathname expansion is performed, so
+ it implements the rules in Posix 2.13.3, specifically that an unquoted
+ slash cannot appear in a bracket expression. */
int
unquoted_glob_pattern_p (string)
register char *string;
@@ -89,6 +92,10 @@ unquoted_glob_pattern_p (string)
return (1);
continue;
+ case '/':
+ if (open)
+ open = 0;
+
case '+':
case '@':
case '!':
@@ -98,7 +105,12 @@ unquoted_glob_pattern_p (string)
case CTLESC:
case '\\':
- if (*string++ == '\0')
+ if (open && *string == '/')
+ {
+ string++; /* quoted slashes in bracket expressions are ok */
+ continue;
+ }
+ else if (*string++ == '\0')
return (0);
}