adji

Adji's a Decisive and Joyful Internet browser
git clone https://noxz.tech/git/adji.git
Log | Files | Tags | LICENSE

commit: 5d38e8a749587963332f5918d9063a697ac45d6f
parent: 90bc012c2898665fe927c138be1c36e7bb2d9dde
author: Chris Noxz <chris@noxz.tech>
date:   Tue, 25 Apr 2023 18:03:12 +0200
enable intepretation of selected text as uri
Mbrowser.c11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/browser.c b/browser.c
@@ -1053,7 +1053,7 @@ selection_search(struct Client *c)
 {
 	webkit_web_view_evaluate_javascript(
 	    WEBKIT_WEB_VIEW(c->wv),
-	    "encodeURIComponent(window.getSelection().toString());",
+	    "window.getSelection().toString();",
 	    -1,
 	    NULL,
 	    NULL,
@@ -1216,7 +1216,8 @@ gchar *
 resolve_uri(const gchar *t)
 {
 	gchar                  *u = NULL,           /* uri to return */
-	                       *l = NULL;           /* temporary string */
+	                       *l = NULL,           /* temporary string */
+	                       *e = NULL;           /* uri encoded string */
 	const gchar            *s = NULL;
 
 	/* check if valid scheme, and if so just create a copy of the text */
@@ -1235,8 +1236,12 @@ resolve_uri(const gchar *t)
 		u = g_strdup(l);
 	/* fallback to web search, using a specified search engine */
 	else
-		u = g_strdup_printf(CFG_S(SearchEngineUriFormat), t);
+		u = g_strdup_printf(
+		    CFG_S(SearchEngineUriFormat),
+		    (e = g_uri_escape_string(t, NULL, FALSE))
+		);
 
+	g_free(e);
 	g_free(l);
 	return u; /* return a pointer that the caller is responsible for freeing */
 }