Skip to content

Commit edbe5fa

Browse files
evallesprebtoor
authored andcommitted
Escape regexp special characters
Apply rebtoor suggestion about adding scaping special characters in role names. So now roles can have special characters "*" and "." as they're escaped. Co-authored-by: Roberto Alfieri <[email protected]> Signed-off-by: Enrique Vallespi Gil <[email protected]>
1 parent 2339605 commit edbe5fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/check-role-prefix.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ ROLE_COUNT=$(echo "$CHANGED_ROLES" | tr '|' '\n' | wc -l)
2525

2626
if [ "$ROLE_COUNT" -eq 1 ]; then
2727
# shellcheck disable=SC1087
28-
PATTERN="^[[(]$CHANGED_ROLES[])]"
28+
ESCAPED_ROLE=$(printf '%s\n' "$CHANGED_ROLES" | sed 's/[]\.*^$()+?{|]/\\&/g')
29+
PATTERN="^[[(]$ESCAPED_ROLE[])]"
2930
else
30-
PATTERN="^[[(]multiple[])]"
31+
PATTERN="^[[(](multiple)[])]"
3132
fi
3233

3334
if ! grep -qE "$PATTERN" <<<"$MSG"; then

0 commit comments

Comments
 (0)