shithub: castor9

Download patch

ref: 877421a1d364851d0a58e5e57b6e13b059db9e5d
parent: fb52dfe4197457eb5eb4134dece22ad42752f31e
author: Julien Blanchard <[email protected]>
date: Sat Dec 26 10:24:38 EST 2020

Fix mailto: links and relative URLs starting with a /

--- a/castor.c
+++ b/castor.c
@@ -616,8 +616,8 @@
 			/* 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));
--- a/url.c
+++ b/url.c
@@ -223,7 +223,10 @@
 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;
 	}