commit c5171f59227742e2e7e1b3b2d82b444d288bff88
parent 23641831d76a194bee4dac1a15ce61f510f8bcb2
Author: Luxferre <lux@ferre>
Date: Thu, 30 Mar 2023 08:34:22 +0300
telnet urls
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git 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
@@ -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