From 21f8ae5db73be083340bb65b4e1ab7ec3abb41b7 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 2 Jan 2022 22:18:57 +0000 Subject: Resolve CGI directories from more to less specific Closes issue #2. --- server/test/src/ServerSpec.scala | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'server/test/src/ServerSpec.scala') diff --git a/server/test/src/ServerSpec.scala b/server/test/src/ServerSpec.scala index dd6bf20..7d8c1fa 100644 --- a/server/test/src/ServerSpec.scala +++ b/server/test/src/ServerSpec.scala @@ -692,6 +692,21 @@ class ServerSpec extends AnyFlatSpec with Matchers { cgi.body should include("PATH_INFO=/path/info") } + it should "resolve CGI directories from more to less specific" in { + // issue: https://gitlab.com/reidrac/spacebeans/-/issues/2 + val cgi = Server(TestData.cgiPrefConf) + .handleReq( + "gemini://localhost/dir/sub/cgiOk/path/info", + "127.0.0.1" + ) + .asInstanceOf[Cgi] + + cgi.status should be(20) + cgi.meta should be("text/gemini") + cgi.body should include("GATEWAY_INTERFACE=CGI/1.1") + cgi.body should include("PATH_INFO=/path/info") + } + object TestData { val host = "localhost" @@ -733,6 +748,30 @@ class ServerSpec extends AnyFlatSpec with Matchers { ) ) + val cgiPrefConf = ServiceConf.initConf( + conf.copy(virtualHosts = + List( + conf + .virtualHosts(0) + .copy( + directoryListing = true, + directories = List( + Directory( + "dir/", + directoryListing = Some(false), + allowCgi = Some(true) + ), + Directory( + "dir/sub/", + directoryListing = Some(false), + allowCgi = Some(true) + ) + ) + ) + ) + ) + ) + val cgiEnvConf = cgiConf.copy(virtualHosts = List( cgiConf -- cgit v1.2.3