[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 20 Mar 2022 04:55:28 -0400 (EDT) |
branch: master
commit a8de8bf58ad1bc47bd255d3b7e82fc17e1598f51
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Nov 8 20:27:11 2019 +0000
open external links with xdg-open
---
js/infog/main.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/js/infog/main.c b/js/infog/main.c
index 4242e8eac2..1e1800cff3 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -658,6 +658,18 @@ hide_index_cb (GtkWidget *widget,
}
+/* Replace any ' characters with '\'' in preparation for being used in a
+ single-quoted string in a shell invocation. */
+void
+escape_uri (char **out, const char *uri)
+{
+ static GRegex *gregex;
+ if (!gregex)
+ gregex = g_regex_new ("'", 0, 0, 0);
+
+ *out = g_regex_replace_literal (gregex, uri, -1, 0, "'\\''", 0, NULL);
+}
+
gboolean
decide_policy_cb (WebKitWebView *web_view,
WebKitPolicyDecision *decision,
@@ -680,6 +692,19 @@ decide_policy_cb (WebKitWebView *web_view,
{
debug (1, "link blocked");
webkit_policy_decision_ignore (decision);
+
+ char *s1 = 0;
+ if (strchr (uri, '\''))
+ {
+ escape_uri (&s1, uri);
+ uri = s1;
+ }
+
+ char *s;
+ asprintf (&s, "xdg-open '%s'", uri);
+ system (s);
+ free (s);
+ free (s1);
}
else
webkit_policy_decision_use (decision);
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20