~julienxx/castor9

118b13927067729a06ecbf923ec6d634d4a8358c — Shawn Nock 3 years ago 8a1c689
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.
2 files changed, 10 insertions(+), 3 deletions(-)

M castor.c
M url.c
M castor.c => castor.c +9 -2
@@ 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);
	}

M url.c => url.c +1 -1
@@ 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;
	}