mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 00:56:11 +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
|
local changed=false
|
||||||
for target in "${targets[@]}"; do
|
for target in "${targets[@]}"; do
|
||||||
local app_path="$target"
|
local app_path="$target"
|
||||||
# Normalize path for comparison - use original path if app already deleted
|
local full_path=""
|
||||||
local full_path
|
|
||||||
if full_path=$(cd "$(dirname "$app_path")" 2> /dev/null && pwd); then
|
if [[ "$app_path" =~ [[:cntrl:]] ]]; then
|
||||||
full_path="$full_path/$(basename "$app_path")"
|
debug_log "Skipping dock removal for path with control chars: $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
|
|
||||||
continue
|
continue
|
||||||
else
|
|
||||||
full_path="$app_path"
|
|
||||||
fi
|
|
||||||
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}"
|
local encoded_path="${full_path// /%20}"
|
||||||
|
|
||||||
# Find the index of the app in persistent-apps
|
# Find the index of the app in persistent-apps
|
||||||
|
|||||||
Reference in New Issue
Block a user