1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-16 08:21:18 +00:00

Fix whitelist issue caused by retrieval list

This commit is contained in:
Tw93
2025-10-14 17:27:38 +08:00
parent 027261a3e1
commit 5ec2ca0c46
2 changed files with 39 additions and 37 deletions

View File

@@ -186,8 +186,8 @@ read_key() {
return 0 return 0
fi fi
case "$key" in case "$key" in
$'\n'|$'\r') echo "ENTER" ;; $'\n' | $'\r') echo "ENTER" ;;
$'\x7f'|$'\x08') echo "DELETE" ;; $'\x7f' | $'\x08') echo "DELETE" ;;
$'\x1b') echo "QUIT" ;; # ESC cancels filter $'\x1b') echo "QUIT" ;; # ESC cancels filter
*) *)
case "$key" in case "$key" in

View File

@@ -97,10 +97,10 @@ paginated_multi_select() {
_pm_escape_glob() { _pm_escape_glob() {
local s="${1-}" out="" c local s="${1-}" out="" c
local i len=${#s} local i len=${#s}
for ((i=0; i<len; i++)); do for ((i = 0; i < len; i++)); do
c="${s:i:1}" c="${s:i:1}"
case "$c" in case "$c" in
'\'|'*'|'?'|'['|']') out+="\\$c" ;; '\' | '*' | '?' | '[' | ']') out+="\\$c" ;;
*) out+="$c" ;; *) out+="$c" ;;
esac esac
done done
@@ -191,11 +191,12 @@ paginated_multi_select() {
# Print footer lines wrapping only at separators # Print footer lines wrapping only at separators
_print_wrapped_controls() { _print_wrapped_controls() {
local sep="$1"; shift local sep="$1"
shift
local -a segs=("$@") local -a segs=("$@")
local cols="${COLUMNS:-}" local cols="${COLUMNS:-}"
[[ -z "$cols" ]] && cols=$(tput cols 2>/dev/null || echo 80) [[ -z "$cols" ]] && cols=$(tput cols 2> /dev/null || echo 80)
_strip_ansi_len() { _strip_ansi_len() {
local text="$1" local text="$1"
@@ -212,7 +213,7 @@ paginated_multi_select() {
else else
candidate="$line${sep}${s}" candidate="$line${sep}${s}"
fi fi
if (( $(_strip_ansi_len "$candidate") > cols )); then if (($(_strip_ansi_len "$candidate") > cols)); then
printf "%s%s\n" "$clear_line" "$line" >&2 printf "%s%s\n" "$clear_line" "$line" >&2
line="$s" line="$s"
else else
@@ -280,14 +281,14 @@ paginated_multi_select() {
# Create temporary file for sorting # Create temporary file for sorting
local tmpfile local tmpfile
tmpfile=$(mktemp 2>/dev/null) || tmpfile="" tmpfile=$(mktemp 2> /dev/null) || tmpfile=""
if [[ -n "$tmpfile" ]]; then if [[ -n "$tmpfile" ]]; then
local k id local k id
for id in "${filtered[@]}"; do for id in "${filtered[@]}"; do
case "$sort_mode" in case "$sort_mode" in
date) k="${epochs[id]:-0}" ;; date) k="${epochs[id]:-0}" ;;
size) k="${sizekb[id]:-0}" ;; size) k="${sizekb[id]:-0}" ;;
name|*) k="${items[id]}|${id}" ;; name | *) k="${items[id]}|${id}" ;;
esac esac
printf "%s\t%s\n" "$k" "$id" >> "$tmpfile" printf "%s\t%s\n" "$k" "$id" >> "$tmpfile"
done done
@@ -296,7 +297,7 @@ paginated_multi_select() {
while IFS=$'\t' read -r _key _id; do while IFS=$'\t' read -r _key _id; do
[[ -z "$_id" ]] && continue [[ -z "$_id" ]] && continue
view_indices+=("$_id") view_indices+=("$_id")
done < <(LC_ALL=C sort -t $'\t' $sort_key -- "$tmpfile" 2>/dev/null) done < <(LC_ALL=C sort -t $'\t' $sort_key -- "$tmpfile" 2> /dev/null)
rm -f "$tmpfile" rm -f "$tmpfile"
else else
@@ -485,7 +486,6 @@ paginated_multi_select() {
printf "${clear_line}" >&2 printf "${clear_line}" >&2
} }
# Main interaction loop # Main interaction loop
while true; do while true; do
draw_menu draw_menu
@@ -499,7 +499,8 @@ paginated_multi_select() {
unset MOLE_READ_KEY_FORCE_CHAR unset MOLE_READ_KEY_FORCE_CHAR
filter_query="" filter_query=""
applied_query="" applied_query=""
top_index=0; cursor_pos=0 top_index=0
cursor_pos=0
rebuild_view rebuild_view
continue continue
fi fi
@@ -560,7 +561,7 @@ paginated_multi_select() {
rebuild_view rebuild_view
fi fi
;; ;;
"CHAR:s"|"CHAR:S") "CHAR:s" | "CHAR:S")
if [[ "$filter_mode" == "true" ]]; then if [[ "$filter_mode" == "true" ]]; then
local ch="${key#CHAR:}" local ch="${key#CHAR:}"
filter_query+="$ch" filter_query+="$ch"
@@ -583,7 +584,7 @@ paginated_multi_select() {
cursor_pos=0 cursor_pos=0
rebuild_view rebuild_view
;; ;;
"CHAR:f"|"CHAR:F") "CHAR:f" | "CHAR:F")
if [[ "$filter_mode" == "true" ]]; then if [[ "$filter_mode" == "true" ]]; then
filter_query+="${key#CHAR:}" filter_query+="${key#CHAR:}"
fi fi
@@ -625,7 +626,8 @@ paginated_multi_select() {
applied_query="$filter_query" applied_query="$filter_query"
filter_mode="false" filter_mode="false"
unset MOLE_READ_KEY_FORCE_CHAR unset MOLE_READ_KEY_FORCE_CHAR
top_index=0; cursor_pos=0 top_index=0
cursor_pos=0
searching="true" searching="true"
draw_menu # paint "searching..." draw_menu # paint "searching..."