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.
---
diff 8a1c689188eee6aecb6ee28d1439a412a2437326 e099cb2cd012f13108efec70cce1ea1cfcdcd208
--- a/castor.c Thu Dec 10 12:50:07 2020
+++ b/castor.c Thu Dec 17 14:25:08 2020
@@ -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 Thu Dec 10 12:50:07 2020
+++ b/url.c Thu Dec 17 14:25:08 2020
@@ -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;
}