From 118b13927067729a06ecbf923ec6d634d4a8358c Mon Sep 17 00:00:00 2001 From: Shawn Nock Date: Thu, 17 Dec 2020 19:34:06 +0000 Subject: [PATCH] Fixes mailto: URI handling Allows URIs without a host segment, such as mailto: to be correctly parsed. Also passes only the path of mailto urls to the plumber to match the default rule. --- castor.c | 11 +++++++++-- url.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/castor.c b/castor.c index b256a14..d9fae91 100644 --- a/castor.c +++ b/castor.c @@ -127,7 +127,14 @@ plumburl(Url *u) fd = plumbopen("send", OWRITE|OCEXEC); if(fd<0) return; - plumbsendtext(fd, "castor9", nil, nil, u->raw); + + char *msg; + if(strcmp(u->scheme, "mailto") == 0){ + msg = u->path; + }else{ + msg = u->raw; + } + plumbsendtext(fd, "castor9", nil, nil, msg); close(fd); freeurl(u); } @@ -606,7 +613,7 @@ texthit(Panel *p, int b, Rtext *rt) }else if(*link == '/'){ n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link)+1); }else{ - n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link)); + n = estrdup(link); } next_url = urlparse(nil, n); } diff --git a/url.c b/url.c index 286df5e..38a9662 100644 --- a/url.c +++ b/url.c @@ -223,7 +223,7 @@ mklowcase(char *s) static Url * saneurl(Url *u) { - if(u == nil || u->scheme == nil || u->host == nil || Upath(u) == nil){ + if(u == nil || u->scheme == nil || Upath(u) == nil){ freeurl(u); return nil; } -- 2.45.2