~sircmpwn/gmni-devel

Check index before serving autoindex v1 APPLIED

Karmanyaah Malhotra: 1
 Check index before serving autoindex

 1 files changed, 6 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/gmni-devel/patches/23416/mbox | git am -3
Learn more about email & git

[PATCH] Check index before serving autoindex Export this patch

if a directory is being served.
---
 src/serve.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/serve.c b/src/serve.c
index 6ad79341..bcbef5c7 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -526,15 +526,16 @@ serve_request(struct gmnisrv_client *client)
		}

		if (S_ISDIR(st.st_mode)) {
			if (route->autoindex) {
				serve_autoindex(client, real_path);
				free(url_path);
				return;
			} else {
				strcpy(temp_path, real_path);
				strncat(real_path,
					route->index ? route->index : "index.gmi",
					sizeof(real_path) - 1);
				if (stat(real_path, &st) != 0) {
					if (route->autoindex) {
						serve_autoindex(client, temp_path);
						free(url_path);
						return;
					}
					server_error("CGI path %s has no index",
						client_path);
					client_submit_response(client,
@@ -542,7 +543,6 @@ serve_request(struct gmnisrv_client *client)
						"Not found", NULL);
					return;
				}
			}
		} else if (S_ISLNK(st.st_mode)) {
			++nlinks;
			if (nlinks > 3) {
-- 
2.32.0
Currently in my experience when enabled, autoindex is rendered
regardless of whether an index.gmi is present
Thanks!

To git@git.sr.ht:~sircmpwn/gmnisrv
   32854b7..9f2481d  master -> master