Skip to content

Commit f7232b7

Browse files
authored
YETUS-1266. Escape regex metacharacters in author plugin ignore list (#366)
The author_postcompile function writes --author-ignore-list entries directly into a grep -E filter file without escaping. Filenames containing regex metacharacters (parentheses, brackets, etc.) are silently misinterpreted as pattern syntax, causing those files to pass through unfiltered.
1 parent 03febdf commit f7232b7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

precommit/src/main/shell/plugins.d/author.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ function author_postcompile
147147
if [[ -z "${AUTHOR_IGNORE_LIST[0]}" ]]; then
148148
cp -p "${PATCH_DIR}/author-tags-git.txt" "${PATCH_DIR}/${AUTHOR_LOGNAME}"
149149
else
150-
printf "^%s\n" "${AUTHOR_IGNORE_LIST[@]}" > "${PATCH_DIR}/author-tags-filter.txt"
150+
for i in "${AUTHOR_IGNORE_LIST[@]}"; do
151+
printf "%s\n" "${i}"
152+
done \
153+
| "${SED}" 's/[][\\.^$*+?{}()|]/\\&/g' \
154+
| "${SED}" 's/^/^/' \
155+
> "${PATCH_DIR}/author-tags-filter.txt"
151156
"${GREP}" -v -E \
152157
-f "${PATCH_DIR}/author-tags-filter.txt" \
153158
"${PATCH_DIR}/author-tags-git.txt" \

0 commit comments

Comments
 (0)