From ef93e01091db0ecc47919782deafd1606fee87b1 Mon Sep 17 00:00:00 2001 From: Solene Rapenne Date: Fri, 1 Jan 2021 16:08:51 +0100 Subject: [PATCH] Remove the port part of the hostname + according test suite patch from prx --- main.c | 7 +++++++ tests/test.sh | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/main.c b/main.c index 5a5d19f..8633f06 100644 --- a/main.c +++ b/main.c @@ -268,6 +268,13 @@ main(int argc, char **argv) */ estrlcpy(file, "/index.gmi", 11); } + /* check if client added :port at end of request */ + pos = strchr(request, ':'); + if (pos != NULL) { + /* end string at :*/ + pos[0] = '\0'; + } + /* copy hostname from request */ estrlcpy(hostname, request, sizeof(hostname)); /* diff --git a/tests/test.sh b/tests/test.sh index 9af2137..7f93a46 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -22,6 +22,10 @@ if ! [ $OUT = "3edd48286850d386592403956aec770f" ] ; then echo "error" ; exit 1 OUT=$(printf "gemini://host.name/\r\n" | ../vger -d var/gemini/ | tee /dev/stderr | $MD5) if ! [ $OUT = "3edd48286850d386592403956aec770f" ] ; then echo "error" ; exit 1 ; fi +# default index.gmi file when client specify port +OUT=$(printf "gemini://host.name:1965\r\n" | ../vger -d var/gemini/ | tee /dev/stderr | $MD5) +if ! [ $OUT = "3edd48286850d386592403956aec770f" ] ; then echo "error" ; exit 1 ; fi + # file from local directory with lang=fr and markdown MIME type OUT=$(printf "gemini://perso.pw/file.md\r\n" | ../vger -d var/gemini/ -l fr | tee /dev/stderr | $MD5) if ! [ $OUT = "e663f17730d5ddc24010c14a238e1e78" ] ; then echo "error" ; exit 1 ; fi