ref: 118b13927067729a06ecbf923ec6d634d4a8358c
parent: 8a1c689188eee6aecb6ee28d1439a412a2437326
author: Shawn Nock <shawn@provisoire.ca>
date: Thu Dec 17 14:34:06 EST 2020
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.
--- a/castor.c
+++ b/castor.c
@@ -127,7 +127,14 @@
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 @@
}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);
}
--- a/url.c
+++ b/url.c
@@ -223,7 +223,7 @@
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;
}