Improved handling %09-separated search URLs
This commit is contained in:
+9
-5
@@ -126,18 +126,22 @@ amclick() { # args: AM line[, forcedl], output: AM line(s)
|
||||
local rport="${fields[3]}"
|
||||
local sel="${fields[4]}"
|
||||
local input=''
|
||||
if [[ 'I' == "$action" ]]; then
|
||||
local puresel="${sel%%\%09*}" # extract the pure selector (w/o possible input)
|
||||
if [[ "$sel" != "$puresel" ]]; then # check selector for %09, if so, extract the input string
|
||||
input="${sel##$puresel\%09}"
|
||||
fi
|
||||
if [[ 'I' == "$action" && -z "$input" ]]; then
|
||||
read -p "${LINECLR}${CURSTART}Enter input for $rhost: " input
|
||||
fi
|
||||
[[ ! -z "$2" ]] && action='D' # force the download action
|
||||
if [[ 'D' == "$action" ]]; then # download
|
||||
local fname="${sel##*/}" # pure-bash version of basename
|
||||
local fname="${puresel##*/}" # pure-bash version of basename
|
||||
[[ -z "$fname" ]] && fname='dl.dat' # just make sure that it's not empty
|
||||
[[ ! -z "$input" ]] && fname="${fname}%09${input}.search.txt"
|
||||
gophetch "$rhost" "$rport" "$sel" "$input" > "$BOPHER_DLDIR/$fname"
|
||||
gophetch "$rhost" "$rport" "$puresel" "$input" > "$BOPHER_DLDIR/$fname"
|
||||
printf 'E\tDownloaded %s to %s\n' "$(amtogopher "$1")" "$BOPHER_DLDIR/$fname"
|
||||
elif [[ 'I' == "$action" || 'M' == "$action" || 'P' == "$action" ]]; then # text content
|
||||
readarray -t lines < <(gophetch "$rhost" "$rport" "$sel" "$input")
|
||||
readarray -t lines < <(gophetch "$rhost" "$rport" "$puresel" "$input")
|
||||
for line in "${lines[@]}"; do # iterate over every fetched line
|
||||
if [[ 'P' == "$action" ]]; then # generate a plaintext AM entry
|
||||
printf 'E\t%s\n' "${line%%$'\r'}" # remove a trailing CR if it's there
|
||||
@@ -235,7 +239,7 @@ amload() { # args: AM line[, forcedl]
|
||||
}
|
||||
|
||||
clicklink() { # click the currently focused link
|
||||
if (( $FOCUSLINEINDEX > -1 )); then
|
||||
if [[ ! -z "$FOCUSLINEINDEX" ]] && (( $FOCUSLINEINDEX > -1 )); then
|
||||
AMHISTORY+=("$CURRENTAM") # update the history chain
|
||||
amload "${SCREENBUF[$FOCUSLINEINDEX]}" "$1"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user