[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.