From c5171f59227742e2e7e1b3b2d82b444d288bff88 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Thu, 30 Mar 2023 08:34:22 +0300 Subject: [PATCH] telnet urls --- README.md | 1 + bopher-ng.sh | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a613a0e..7b7feee 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Improvements over the original Bopher from that post: - ability to accept `gopher://` URLs from the command line - ability to save the URL to the currently viewed resource into the stash text file - ability to force-download pages instead of viewing regardless of their type +- ability to display 8-type Gophermap entries as `telnet://` URIs (not opening anything for security reasons) "Pure Bash" means any external commands must only be used if absolutely required. For now, Bopher-NG only depends on three external commands (all POSIX-compliant): diff --git a/bopher-ng.sh b/bopher-ng.sh index e91a48b..538bbc5 100755 --- a/bopher-ng.sh +++ b/bopher-ng.sh @@ -12,6 +12,7 @@ # - ability to accept gopher:// URLs from the command line # - ability to save the URL to the currently viewed resource into the stash text file # - ability to force-download pages instead of viewing regardless of their type +# - displaying type 8 entries (as per RFC1436) as the telnet:// URI scheme # save the command line parameters @@ -100,11 +101,13 @@ gmparse() { # args: line, curhost, curport [[ -z "$rhost" ]] && rhost="$2" # fill in the missing hostname [[ -z "$rport" ]] && rport="$3" # fill in the missing port number local action='D' # all unknown types are set to download - if [[ 'i' == "$rtype" || '3' == "$rtype" || 'h' == "$rtype" ]]; then # handle information lines + if [[ 'i' == "$rtype" || '3' == "$rtype" || 'h' == "$rtype" || '8' == "$rtype" ]]; then # handle information lines action='E' [[ '3' == "$rtype" ]] && desc="$ERRCOLOR$desc$ERESET" # wrap error messages in the coloration terminal commands # handle external URLs as information lines of a special kind [[ 'h' == "$rtype" ]] && desc="$desc: ${sel#URL:}" + # handle 8-type resources as telnet:// URIs + [[ '8' == "$rtype" ]] && desc="$desc: telnet://${sel}@${rhost}:${rport}/" fi [[ '0' == "$rtype" ]] && action='P' # plain text is plain text [[ '1' == "$rtype" ]] && action='M' # it's a Gophermap