astro

a POSIX shell compatible gemini client (mirror of https://github.com/blmayer/astro)
git clone https://git.clttr.info/astro.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit e9b6580368b7858bd4903bf8fd04f22071a0c2ac
parent 35b55b0847f160e9713ced57030788a11fcfc5c0
Author: René Wagner <rwa@clttr.info>
Date:   Sat,  5 Aug 2023 18:28:31 +0200

use mimetype to decide if typesetting is needed (#38)

Use mimetype to decide if typesetting is needed

When the path portion of the URI contains . - for example in the query part
like in `geminispace.info/search?test.com` - the page is not handled by `typesetgmi`.
Instead of matching the `path` part of the URI we check the mimetype from meta instead.

I'm currently unsure if the dot in a query part should be percent-encoded anyway (quick research
lead to ambiguous results). At least for now astro does not percent-encode it.
Diffstat:
Mastro | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/astro b/astro @@ -192,7 +192,7 @@ typesetgmi() { sty="$sty_linkt" line="$(echo "$sty_linkb$sty_linkt" | sed "s/%linkcount/$linkcount/g")$line" - debug "link line: $line" + #debug "link line: $line" ;; '* '*) sty="$sty_listt" && line="$sty_listb$sty_listt$(echo "$line" | cut -c 2-)";; *) sty="";; @@ -277,7 +277,7 @@ EOF status="$(echo "$status" | tr -d '\r\n')" meta="$(echo "$meta" | tr -d '\r\n')" sed -i '1d' "$pagefile" - debug "response header: $status $meta" + debug "response status - meta: $status - $meta" # Validate case "$status" in @@ -382,10 +382,9 @@ EOF esac debug "charset: $charset" - case $4 in - *".gmi"|"") typesetgmi ;; - *.*) cat ;; - *) typesetgmi ;; + case $meta in + "text/gemini"* | "") typesetgmi ;; + *) cat ;; esac < "$pagefile" | LESSCHARSET="$charset" less -k "$LESSKEY" +k -R code="$?" rm "$pagefile"