From 57c4d4c8527ac5b0f08e4d530f617fcaeb35f10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=99=AE?= Date: Mon, 14 Jun 2021 11:58:50 -0700 Subject: [PATCH] Added support for user input with selector 7 --- gmi2gph.awk | 4 ++-- tannhauser.dcgi | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gmi2gph.awk b/gmi2gph.awk index 4ee4796..fca3604 100755 --- a/gmi2gph.awk +++ b/gmi2gph.awk @@ -47,7 +47,7 @@ BEGIN { else for (i = 3; i <= NF; i++) printf("%s ", $i) - printf("|/tannhauser.dcgi?%s%s|localhost|70]\n", host, $2) + printf("|/tannhauser.dcgi?%s%s|localhost|70]\n", path, $2) } else if (substr($2, 0, 2) == "//") { # Sans gemini: sub(/\/\//, "", $2) @@ -67,7 +67,7 @@ BEGIN { else for (i = 3; i <= NF; i++) printf("%s ", $i) - printf("|/tannhauser.dcgi?%s%s|localhost|70]\n", host, $2) + printf("|/tannhauser.dcgi?%s/%s|localhost|70]\n", path, $2) } } else { # This line is not a hyperlink print $0 diff --git a/tannhauser.dcgi b/tannhauser.dcgi index 9302872..01f259f 100755 --- a/tannhauser.dcgi +++ b/tannhauser.dcgi @@ -34,6 +34,17 @@ if [ -n "$cgiargs" ]; then # We're following a link through the proxy url="gemini://$cgiargs" host="$(echo "$cgiargs" | cut -d '/' -f1)" gatepath="$cgiargs" +elif [ -n "$cgisearch" ]; then # Process user input + if [ "$(echo "$cgisearch" | cut -d '/' -f1)" = "gemini:" ]; then + # gemini://host.tld/path + url="$cgisearch" + host="$(echo "$cgisearch" | cut -d '/' -f3)" + gatepath="${cgisearch%%gemini://}" + else + url="gemini://$cgisearch" + host="$(echo "$cgisearch" | cut -d '/' -f1)" + gatepath="$cgisearch" + fi else printf "CGI Error: \$cgisearch and \$cgiargs are empty\n" print_debug -- 2.45.2