From 521f8b855c2aed5e229779ba40a0e62078e61988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 21 Jan 2021 00:39:15 +0100 Subject: [PATCH] introduced general pdi unescape function --- cards/index.cgi | 1 - courses/index.cgi | 1 - pdiread.sh | 10 ++++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cards/index.cgi b/cards/index.cgi index f1306f6..90be142 100755 --- a/cards/index.cgi +++ b/cards/index.cgi @@ -11,7 +11,6 @@ fi . $_EXEC/cards/widgets.sh . $_EXEC/cards/list.sh -unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; } upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; ' filter="$(GET f)" diff --git a/courses/index.cgi b/courses/index.cgi index 56db2fa..e98d7b6 100755 --- a/courses/index.cgi +++ b/courses/index.cgi @@ -11,7 +11,6 @@ fi . $_EXEC/courses/widgets.sh . $_EXEC/courses/list.sh -unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; } upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; ' order="$(GET o |grep -m1 -xE 'DOW|TOD')" diff --git a/pdiread.sh b/pdiread.sh index 6f15658..08fbaec 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -26,6 +26,16 @@ include_pdi="$0" BR=' ' +unescape() { + local unescape='s;(^(\\\\)*|[^\\](\\\\)*)\\n;\1\n;g; s;\\(.);\1;g' + if [ $# -eq 0 ]; then + sed -E "$unescape" + else + printf %s "$*" \ + | sed -E "$unescape" + fi +} + pdi_load() { # normalise PDI file for processing with pdi_* functions # functions in this library can only be applied to normalised data -- 2.39.2