mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 18:10:17 +00:00
fix: improve Dock cleanup path handling
- Add control character validation - Use canonical paths (pwd -P) for better resolution - Strengthen fallback logic for deleted applications - Add empty path guards
This commit is contained in:
@@ -125,24 +125,29 @@ remove_apps_from_dock() {
|
||||
local changed=false
|
||||
for target in "${targets[@]}"; do
|
||||
local app_path="$target"
|
||||
# Normalize path for comparison - use original path if app already deleted
|
||||
local full_path
|
||||
if full_path=$(cd "$(dirname "$app_path")" 2> /dev/null && pwd); then
|
||||
full_path="$full_path/$(basename "$app_path")"
|
||||
else
|
||||
# App already deleted - use the original path as-is
|
||||
# Remove ~/ prefix and expand to full path if needed
|
||||
if [[ "$app_path" == ~/* ]]; then
|
||||
full_path="$HOME/${app_path#~/}"
|
||||
elif [[ "$app_path" != /* ]]; then
|
||||
# Relative path - skip this entry
|
||||
local full_path=""
|
||||
|
||||
if [[ "$app_path" =~ [[:cntrl:]] ]]; then
|
||||
debug_log "Skipping dock removal for path with control chars: $app_path"
|
||||
continue
|
||||
else
|
||||
full_path="$app_path"
|
||||
fi
|
||||
fi
|
||||
|
||||
# URL-encode the path for matching against Dock URLs (spaces -> %20)
|
||||
if [[ -e "$app_path" ]]; then
|
||||
if full_path=$(cd "$(dirname "$app_path")" 2>/dev/null && pwd -P); then
|
||||
full_path="$full_path/$(basename "$app_path")"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
else
|
||||
case "$app_path" in
|
||||
~/*) full_path="$HOME/${app_path#~/}" ;;
|
||||
/*) full_path="$app_path" ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
[[ -z "$full_path" ]] && continue
|
||||
|
||||
local encoded_path="${full_path// /%20}"
|
||||
|
||||
# Find the index of the app in persistent-apps
|
||||
|
||||
Reference in New Issue
Block a user