From 634d3aa5daf5404f2d209512acf70c601ece5697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 22 Sep 2023 19:21:15 +0200 Subject: [PATCH] bugfix: backslash escaping --- handlers/40_search.sh | 4 ++-- parsers/40_indexer.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers/40_search.sh b/handlers/40_search.sh index d198f22..6ac6dce 100644 --- a/handlers/40_search.sh +++ b/handlers/40_search.sh @@ -8,9 +8,9 @@ I="$_DATA/index" words="$( GET q | awk ' BEGIN { # Field separator FS should include punctuation, including Unicode Block U+2000 - U+206F if ( length("¡") == 1 ) # Utf-8 aware AWK - FS = "([] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+"; else # UTF-8 Hack - FS = "([] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; fi } { for (n = 1; n <= NF; n++) printf "%s ", tolower($n); } diff --git a/parsers/40_indexer.sh b/parsers/40_indexer.sh index e3065c1..08060f1 100755 --- a/parsers/40_indexer.sh +++ b/parsers/40_indexer.sh @@ -36,9 +36,9 @@ done \ | awk ' BEGIN { # Field separator FS should include punctuation, including Unicode Block U+2000 - U+206F if ( length("¡") == 1 ) # Utf-8 aware AWK - FS = "([] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+"; else # UTF-8 Hack - FS = "([] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; fi } { for (n = 1; n <= NF; n++) { @@ -47,7 +47,7 @@ done \ } } } END { for (w in words) printf "%i %i %f %s\n", words[w], total, words[w] / total, w; } ' \ -| while read num total freq word; do +| while read -r num total freq word; do [ "$word" ] || continue F="$I/$word" L="$(STRING "$DOC")" -- 2.39.2