~julienxx/castor9

877421a1d364851d0a58e5e57b6e13b059db9e5d — Julien Blanchard 3 years ago fb52dfe
Fix mailto: links and relative URLs starting with a /
2 files changed, 6 insertions(+), 3 deletions(-)

M castor.c
M url.c
M castor.c => castor.c +2 -2
@@ 616,8 616,8 @@ texthit(Panel *p, int b, Rtext *rt)
			/* no slash, must be a hostname */
			n = smprint("gemini://%s", current_base_url->host);
		}else if(*link == '/'){
			/* start with a slash so skip it (+1) */
			n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link)+1);
			/* start with a slash so use the base host */
			n = smprint("gemini://%s%s", current_base_url->host, estrdup(link));
		}else{
			/* make an absolute URL of the link */
			n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link));

M url.c => url.c +4 -1
@@ 223,7 223,10 @@ mklowcase(char *s)
static Url *
saneurl(Url *u)
{
	if(u == nil || u->scheme == nil || Upath(u) == nil){
	if(strcmp(u->scheme, "mailto") == 0 && Upath(u) != nil)
		return u;

	if(u == nil || u->scheme == nil || u->host == nil || Upath(u) == nil){
		freeurl(u);
		return nil;
	}