~sircmpwn/gmni-devel

gmni: gmnlm: allow ~ as home alias in file:// URLs v1 REJECTED

Ondřej Fiala: 1
 gmnlm: allow ~ as home alias in file:// URLs

 1 files changed, 13 insertions(+), 0 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/33491/mbox | git am -3
Learn more about email & git

[PATCH gmni] gmnlm: allow ~ as home alias in file:// URLs Export this patch

---
 src/gmnlm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/gmnlm.c b/src/gmnlm.c
index 884796c..de5428f 100644
--- a/src/gmnlm.c
+++ b/src/gmnlm.c
@@ -425,6 +425,19 @@ do_requests(struct browser *browser, struct gemini_response *resp)
				break;
			}

			if (path[0] == '~') {
				char *home = getenv("HOME");
				int sz = strlen(home) + strlen(&path[1]) + 1;
				char *newpath = malloc(sz);
				if (!newpath) return GEMINI_ERR_OOM;

				int n = snprintf(newpath, sz, "%s%s",
						home, &path[1]);
				assert(n >= 0 && n < sz);
				free(path);
				path = newpath;
			}

			int fd = open(path, O_RDONLY);
			if (fd < 0) {
				resp->status = GEMINI_STATUS_NOT_FOUND;
-- 
2.36.1
I'd rather not do this one.