From d6c1406a5507f83acc0433189ad89d40560f1f08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 18 Jul 2018 07:51:03 +0200 Subject: [PATCH] allow white space in search, bugfix: no double escaping in filename lists --- list.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/list.sh b/list.sh index d729c6c..e8b7075 100644 --- a/list.sh +++ b/list.sh @@ -4,9 +4,10 @@ . "$_EXEC/widgets.sh" list_item() { - local name path length width height tags comment n + local name link path length width height tags comment n name="$(HTML "$1")" - path="$(URL "$ITEM/$1")" + link="$(URL "$ITEM/$1")" + path="$(HTML "$ITEM/$1")" qry=$(HTML "$QUERY_STRING") if [ -d "$_DATA/$ITEM/$1" ]; then @@ -18,9 +19,9 @@ list_item() { printf '[div .list .file [a href="%s" [img src="%s?a=thumbnail"][label %s]] [span .time %i:%imin] [span .dim %ix%i] %s - [checkbox "select" "%s" id="select_%s" form="multitag"][label for="select_%s" +] + [checkbox "select" "%s" id="select_%s"][label for="select_%s" +] ]' \ - "$path" "$path" "$name" \ + "$link" "$link" "$name" \ "$((length / 60))" "$((length % 60))" \ "$width" "$height" \ "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \ @@ -69,20 +70,20 @@ list_filemeta(){ if [ $ORDER = Name ]; then sort -k6 "$meta" elif [ $ORDER = Length ]; then - sort -n "$meta" + sort -n -k1 "$meta" else cat "$meta" fi \ | if [ "$FILTER" ]; then sed -nr "$list_fex" elif [ "${SEARCH#!}" != "${SEARCH}" ]; then - grep -viE "$(STRING "${SEARCH#!}")" + grep -aviE "$(STRING "${SEARCH#!}" |sed -r 's;((^|[^\\])(\\\\)*)\+;\1\\+;g;')" else - grep -iE "$(STRING "${SEARCH}")" + grep -aiE "$(STRING "${SEARCH}" |sed -r 's;((^|[^\\])(\\\\)*)\+;\1\\+;g;')" fi |cut -f6 | UNSTRING \ | while read -r fn; do printf '%s\n' "${base}/${fn%${CR}}" - done + done | tee .index/debug } list_index(){ @@ -105,7 +106,7 @@ list_dateorder(){ list_items() { local mode - mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )" + mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )" [ "$mode" = browse -a "$ITEM" ] && printf '..\n' @@ -124,7 +125,7 @@ list_items() { list_paginate() { local page i c n end - page="$(GET p |grep -xE '[0-9]+' || printf 1)"; c=1 + page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1 end=$((page + LISTSIZE)) printf '[div .itemlist ' -- 2.39.2