From 5cd2aaf555f1606f57fd032900290a26605d6919 Mon Sep 17 00:00:00 2001 From: Clathweppes <140804675+Clathweppes@users.noreply.github.com> Date: Tue, 18 Nov 2025 10:17:55 +0800 Subject: [PATCH] fix:Adjust string matching regex to support spaces and asterisks at any position in whitelist path, and add Rust documentation whitelist option (#56) * Add Rust documentation whitelist option * 1.9.11 * fix: allow spaces and wildcards anywhere in whitelist paths * Change code comments --------- Co-authored-by: Tw93 --- bin/clean.sh | 6 +++--- lib/whitelist_manager.sh | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/clean.sh b/bin/clean.sh index 0302bc3..3500b5a 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -56,9 +56,9 @@ if [[ -f "$HOME/.config/mole/whitelist" ]]; then # Expand tilde to home directory [[ "$line" == ~* ]] && line="${line/#~/$HOME}" - # Stricter path validation (no spaces, wildcards only at end) - # Allow: letters, numbers, /, _, ., -, @ and * only at the end - if [[ ! "$line" =~ ^[a-zA-Z0-9/_.@-]+(\*)?$ ]]; then + # Path validation with support for spaces and wildcards + # Allow: letters, numbers, /, _, ., -, @, spaces, and * anywhere in path + if [[ ! "$line" =~ ^[a-zA-Z0-9/_.@\ *-]+$ ]]; then WHITELIST_WARNINGS+=("Invalid path format: $line") continue fi diff --git a/lib/whitelist_manager.sh b/lib/whitelist_manager.sh index 3ee9b98..059eaef 100755 --- a/lib/whitelist_manager.sh +++ b/lib/whitelist_manager.sh @@ -82,6 +82,7 @@ Bazel build cache|$HOME/.cache/bazel/*|compiler_cache Go build cache and module cache|$HOME/Library/Caches/go-build/*|compiler_cache Go module cache|$HOME/go/pkg/mod/cache/*|compiler_cache Rust Cargo registry cache|$HOME/.cargo/registry/cache/*|compiler_cache +Rust documentation cache|$HOME/.rustup/toolchains/*/share/doc/*|compiler_cache Rustup toolchain downloads|$HOME/.rustup/downloads/*|compiler_cache ccache compiler cache|$HOME/.ccache/*|compiler_cache sccache distributed compiler cache|$HOME/.cache/sccache/*|compiler_cache