From 84f73eca9864a516dba6c0a8d90b9d45c94dfaad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 10 Aug 2023 18:47:05 +0200 Subject: [PATCH] implement redirect pragma --- handlers/20_redirect.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 handlers/20_redirect.sh diff --git a/handlers/20_redirect.sh b/handlers/20_redirect.sh new file mode 100755 index 0000000..9f3497e --- /dev/null +++ b/handlers/20_redirect.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +case $PATH_INFO in + *"/["*"]") + return 1; + ;; +esac + +if acl_read ${PATH_INFO}; then + mdfile="$(mdfile "${PATH_INFO%/*}")" +else + return 1 +fi + +if [ "$mdfile" ]; then + REDIRECT="$( + sed -nE ' + s;^%redirect[ \t]+([[:graph:]][[:print:]]+)\r?$;\1;p; tQ; + b; :Q q; + ' "$mdfile" + )" +else + return 1 +fi + +if [ "$REDIRECT" ]; then + REDIRECT "$REDIRECT" +fi + +return 1 -- 2.39.2