Fix hang if non-existing label is searched.

master
tYYGH 2016-01-21 23:17:09 +01:00
parent 0a07c43cdf
commit c66afedb17
2 changed files with 4 additions and 2 deletions

2
README
View File

@ -24,6 +24,8 @@ The solution is to allow the web server user to execute a single command as anot
* the command-line interface, that is run on the server by a user with read access to the documents;
* the web interface, that is run on the web server, with no access to the documents save through the CLI interface.
Finally, all the input (search terms, etc.) is verified by the CLI script, so that any number of frontends can be written and benefit from the same strict controls.
= INSTALLATION AND DEPENDENCIES =
The script may be copied anywhere. Its dependencies are standard, although I only tested on Debian: bash, find, gawk, sed, grep, file, ls.

View File

@ -102,7 +102,7 @@ Q)
if [ ${#labels[*]} -gt 0 ]; then
# This is an AND
for l in "${labels[@]}"; do
found="$(
[ -n "$found" ] && found="$(
eval grep -lF${q_ci:+i}e "$l" ${found//|/labels} 2>/dev/null \
| sed 's#labels$#|#')"
done
@ -111,7 +111,7 @@ Q)
# eval grep -lF${q_ci:+i}f <(printf '%s\n' "${labels[@]}") ${found//|/labels} 2>/dev/null \
# | sed 's#labels$#|#')"
fi
if [ ${#words[*]} -gt 0 ]; then
if [ ${#words[*]} -gt 0 ] && [ -n "$found" ]; then
# This is an AND
tmpf="$(
eval grep -Ho "'>[^<>]*</span'" ${found//|/paper.*.words} 2>/dev/null \